Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
92214eaf
Commit
92214eaf
authored
Jul 29, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Part II for ticket #2352. Fixed #2352.
parent
2ec4cc5c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
141 additions
and
12 deletions
+141
-12
ArrayCollection.php
lib/Doctrine/Common/Collections/ArrayCollection.php
+1
-1
Collection.php
lib/Doctrine/Common/Collections/Collection.php
+129
-0
ObjectHydrator.php
lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
+2
-2
PersistentCollection.php
lib/Doctrine/ORM/PersistentCollection.php
+1
-1
UnitOfWork.php
lib/Doctrine/ORM/UnitOfWork.php
+6
-6
AbstractManyToManyAssociationTestCase.php
.../ORM/Functional/AbstractManyToManyAssociationTestCase.php
+2
-2
No files found.
lib/Doctrine/Common/Collections/ArrayCollection.php
View file @
92214eaf
...
@@ -30,7 +30,7 @@ use \Closure, \ArrayIterator;
...
@@ -30,7 +30,7 @@ use \Closure, \ArrayIterator;
* @author Roman S. Borschel <roman@code-factory.org>
* @author Roman S. Borschel <roman@code-factory.org>
* @since 2.0
* @since 2.0
*/
*/
class
ArrayCollection
implements
I
Collection
class
ArrayCollection
implements
Collection
{
{
/**
/**
* An array containing the entries of this collection.
* An array containing the entries of this collection.
...
...
lib/Doctrine/Common/Collections/Collection.php
0 → 100644
View file @
92214eaf
<?php
namespace
Doctrine\Common\Collections
;
/**
* The missing (SPL) Collection/Array interface.
* A Collection resembles the nature of a regular PHP array. That is,
* it is essentially an ordered map that can syntactically also be used
* like a list.
*
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
*/
interface
Collection
extends
\Countable
,
\IteratorAggregate
,
\ArrayAccess
{
/**
* Adds an element to the collection.
*
* @param mixed $element The element to add.
* @return boolean Always TRUE.
*/
function
add
(
$element
);
/**
* Clears the collection.
*/
function
clear
();
/**
* Checks whether an element is contained in the collection.
* This is an O(n) operation.
*
* @param mixed $element The element to check for.
* @return boolean TRUE if the collection contains the element, FALSE otherwise.
*/
function
contains
(
$element
);
/**
* Checks whether the collection is empty.
*
* @return boolean TRUE if the collection is empty, FALSE otherwise.
*/
function
isEmpty
();
/**
* Removes the element with the specified key/index from the collection.
*
* @param string|integer $key The key/index of the element to remove.
* @return mixed The removed element or NULL, if the collection did not contain the element.
*/
function
remove
(
$key
);
/**
* Removes an element from the collection.
*
* @param mixed $element The element to remove.
* @return mixed The removed element or NULL, if the collection did not contain the element.
*/
function
removeElement
(
$element
);
/**
* Checks whether the collection contains an element with the specified key/index.
*
* @param string|integer $key The key/index to check for.
* @return boolean TRUE if the collection contains an element with the specified key/index,
* FALSE otherwise.
*/
function
containsKey
(
$key
);
/**
* Gets an element with a specified key / at a specified index.
*
* @param string|integer $key The key/index of the element to retrieve.
* @return mixed
*/
function
get
(
$key
);
/**
* Gets all keys/indices of the collection.
*
* @return array The keys/indices of the collection, in the order of the corresponding
* elements in the collection.
*/
function
getKeys
();
/**
* Gets all values of the collection.
*
* @return array The values of all elements in the collection, in the order they
* appear in the collection.
*/
function
getValues
();
/**
* Sets an element in the collection at the specified key/index.
*
* @param string|integer $key The key/index of the element to set.
* @param mixed $value The element to set.
*/
function
set
(
$key
,
$value
);
/**
* Counts the elements in the collection.
*
* @return integer The number of elements in the collection.
*/
//function count();
/**
* Gets a plain PHP array representation of the collection.
*
* @return array
*/
function
toArray
();
/**
* Gets the first element of the collection.
*
* @return mixed
*/
function
first
();
/**
* Gets the last element of the collection.
*
* @return mixed
*/
function
last
();
}
\ No newline at end of file
lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
View file @
92214eaf
...
@@ -25,7 +25,7 @@ use Doctrine\DBAL\Connection,
...
@@ -25,7 +25,7 @@ use Doctrine\DBAL\Connection,
Doctrine\ORM\PersistentCollection
,
Doctrine\ORM\PersistentCollection
,
Doctrine\ORM\Query
,
Doctrine\ORM\Query
,
Doctrine\Common\Collections\ArrayCollection
,
Doctrine\Common\Collections\ArrayCollection
,
Doctrine\Common\Collections\
I
Collection
;
Doctrine\Common\Collections\Collection
;
/**
/**
* The ObjectHydrator constructs an object graph out of an SQL result set.
* The ObjectHydrator constructs an object graph out of an SQL result set.
...
@@ -147,7 +147,7 @@ class ObjectHydrator extends AbstractHydrator
...
@@ -147,7 +147,7 @@ class ObjectHydrator extends AbstractHydrator
if
(
!
is_object
(
$coll
))
{
if
(
!
is_object
(
$coll
))
{
end
(
$coll
);
end
(
$coll
);
$this
->
_resultPointers
[
$dqlAlias
]
=&
$coll
[
key
(
$coll
)];
$this
->
_resultPointers
[
$dqlAlias
]
=&
$coll
[
key
(
$coll
)];
}
else
if
(
$coll
instanceof
I
Collection
)
{
}
else
if
(
$coll
instanceof
Collection
)
{
if
(
count
(
$coll
)
>
0
)
{
if
(
count
(
$coll
)
>
0
)
{
$this
->
_resultPointers
[
$dqlAlias
]
=
$coll
->
last
();
$this
->
_resultPointers
[
$dqlAlias
]
=
$coll
->
last
();
}
}
...
...
lib/Doctrine/ORM/PersistentCollection.php
View file @
92214eaf
...
@@ -44,7 +44,7 @@ use Doctrine\Common\DoctrineException,
...
@@ -44,7 +44,7 @@ use Doctrine\Common\DoctrineException,
* @author Roman Borschel <roman@code-factory.org>
* @author Roman Borschel <roman@code-factory.org>
* @author Giorgio Sironi <piccoloprincipeazzurro@gmail.com>
* @author Giorgio Sironi <piccoloprincipeazzurro@gmail.com>
*/
*/
final
class
PersistentCollection
implements
\Doctrine\Common\Collections\
I
Collection
final
class
PersistentCollection
implements
\Doctrine\Common\Collections\Collection
{
{
/**
/**
* A snapshot of the collection at the moment it was fetched from the database.
* A snapshot of the collection at the moment it was fetched from the database.
...
...
lib/Doctrine/ORM/UnitOfWork.php
View file @
92214eaf
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
namespace
Doctrine\ORM
;
namespace
Doctrine\ORM
;
use
Doctrine\Common\Collections\ArrayCollection
,
use
Doctrine\Common\Collections\ArrayCollection
,
Doctrine\Common\Collections\
I
Collection
,
Doctrine\Common\Collections\Collection
,
Doctrine\Common\DoctrineException
,
Doctrine\Common\DoctrineException
,
Doctrine\Common\PropertyChangedListener
,
Doctrine\Common\PropertyChangedListener
,
Doctrine\ORM\Event\LifecycleEventArgs
,
Doctrine\ORM\Event\LifecycleEventArgs
,
...
@@ -1455,7 +1455,7 @@ class UnitOfWork implements PropertyChangedListener
...
@@ -1455,7 +1455,7 @@ class UnitOfWork implements PropertyChangedListener
continue
;
continue
;
}
}
$relatedEntities
=
$class
->
reflFields
[
$assocMapping
->
sourceFieldName
]
->
getValue
(
$entity
);
$relatedEntities
=
$class
->
reflFields
[
$assocMapping
->
sourceFieldName
]
->
getValue
(
$entity
);
if
(
$relatedEntities
instanceof
I
Collection
)
{
if
(
$relatedEntities
instanceof
Collection
)
{
foreach
(
$relatedEntities
as
$relatedEntity
)
{
foreach
(
$relatedEntities
as
$relatedEntity
)
{
$this
->
_doRefresh
(
$relatedEntity
,
$visited
);
$this
->
_doRefresh
(
$relatedEntity
,
$visited
);
}
}
...
@@ -1479,7 +1479,7 @@ class UnitOfWork implements PropertyChangedListener
...
@@ -1479,7 +1479,7 @@ class UnitOfWork implements PropertyChangedListener
continue
;
continue
;
}
}
$relatedEntities
=
$class
->
reflFields
[
$assocMapping
->
sourceFieldName
]
->
getValue
(
$entity
);
$relatedEntities
=
$class
->
reflFields
[
$assocMapping
->
sourceFieldName
]
->
getValue
(
$entity
);
if
(
$relatedEntities
instanceof
I
Collection
)
{
if
(
$relatedEntities
instanceof
Collection
)
{
foreach
(
$relatedEntities
as
$relatedEntity
)
{
foreach
(
$relatedEntities
as
$relatedEntity
)
{
$this
->
_doDetach
(
$relatedEntity
,
$visited
);
$this
->
_doDetach
(
$relatedEntity
,
$visited
);
}
}
...
@@ -1504,7 +1504,7 @@ class UnitOfWork implements PropertyChangedListener
...
@@ -1504,7 +1504,7 @@ class UnitOfWork implements PropertyChangedListener
continue
;
continue
;
}
}
$relatedEntities
=
$class
->
reflFields
[
$assocMapping
->
sourceFieldName
]
->
getValue
(
$entity
);
$relatedEntities
=
$class
->
reflFields
[
$assocMapping
->
sourceFieldName
]
->
getValue
(
$entity
);
if
(
$relatedEntities
instanceof
I
Collection
)
{
if
(
$relatedEntities
instanceof
Collection
)
{
foreach
(
$relatedEntities
as
$relatedEntity
)
{
foreach
(
$relatedEntities
as
$relatedEntity
)
{
$this
->
_doMerge
(
$relatedEntity
,
$visited
,
$managedCopy
,
$assocMapping
);
$this
->
_doMerge
(
$relatedEntity
,
$visited
,
$managedCopy
,
$assocMapping
);
}
}
...
@@ -1529,7 +1529,7 @@ class UnitOfWork implements PropertyChangedListener
...
@@ -1529,7 +1529,7 @@ class UnitOfWork implements PropertyChangedListener
continue
;
continue
;
}
}
$relatedEntities
=
$class
->
reflFields
[
$assocMapping
->
sourceFieldName
]
->
getValue
(
$entity
);
$relatedEntities
=
$class
->
reflFields
[
$assocMapping
->
sourceFieldName
]
->
getValue
(
$entity
);
if
((
$relatedEntities
instanceof
I
Collection
||
is_array
(
$relatedEntities
)))
{
if
((
$relatedEntities
instanceof
Collection
||
is_array
(
$relatedEntities
)))
{
foreach
(
$relatedEntities
as
$relatedEntity
)
{
foreach
(
$relatedEntities
as
$relatedEntity
)
{
$this
->
_doPersist
(
$relatedEntity
,
$visited
);
$this
->
_doPersist
(
$relatedEntity
,
$visited
);
}
}
...
@@ -1554,7 +1554,7 @@ class UnitOfWork implements PropertyChangedListener
...
@@ -1554,7 +1554,7 @@ class UnitOfWork implements PropertyChangedListener
}
}
$relatedEntities
=
$class
->
reflFields
[
$assocMapping
->
sourceFieldName
]
$relatedEntities
=
$class
->
reflFields
[
$assocMapping
->
sourceFieldName
]
->
getValue
(
$entity
);
->
getValue
(
$entity
);
if
(
$relatedEntities
instanceof
I
Collection
||
is_array
(
$relatedEntities
))
{
if
(
$relatedEntities
instanceof
Collection
||
is_array
(
$relatedEntities
))
{
foreach
(
$relatedEntities
as
$relatedEntity
)
{
foreach
(
$relatedEntities
as
$relatedEntity
)
{
$this
->
_doRemove
(
$relatedEntity
,
$visited
);
$this
->
_doRemove
(
$relatedEntity
,
$visited
);
}
}
...
...
tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php
View file @
92214eaf
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
namespace
Doctrine\Tests\ORM\Functional
;
namespace
Doctrine\Tests\ORM\Functional
;
use
Doctrine\Common\Collections\
I
Collection
;
use
Doctrine\Common\Collections\Collection
;
require_once
__DIR__
.
'/../../TestInit.php'
;
require_once
__DIR__
.
'/../../TestInit.php'
;
...
@@ -36,7 +36,7 @@ class AbstractManyToManyAssociationTestCase extends \Doctrine\Tests\OrmFunctiona
...
@@ -36,7 +36,7 @@ class AbstractManyToManyAssociationTestCase extends \Doctrine\Tests\OrmFunctiona
->
fetchAll
());
->
fetchAll
());
}
}
public
function
assertCollectionEquals
(
ICollection
$first
,
I
Collection
$second
)
public
function
assertCollectionEquals
(
Collection
$first
,
Collection
$second
)
{
{
return
$first
->
forAll
(
function
(
$k
,
$e
)
use
(
$second
)
{
return
$second
->
contains
(
$e
);
});
return
$first
->
forAll
(
function
(
$k
,
$e
)
use
(
$second
)
{
return
$second
->
contains
(
$e
);
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment