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
82c41668
Commit
82c41668
authored
Jul 28, 2009
by
piccoloprincipe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] resolved hydrateAdd() recursivity
parent
c073f1d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
7 deletions
+5
-7
PersistentCollection.php
lib/Doctrine/ORM/PersistentCollection.php
+4
-6
ManyToManyBidirectionalAssociationTest.php
...ORM/Functional/ManyToManyBidirectionalAssociationTest.php
+1
-1
No files found.
lib/Doctrine/ORM/PersistentCollection.php
View file @
82c41668
...
...
@@ -203,13 +203,10 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
*
* @param mixed $element The element to add.
*/
public
function
hydrateAdd
(
$element
)
public
function
hydrateAdd
(
$element
,
$setBackRef
=
true
)
{
if
(
parent
::
contains
(
$element
))
{
return
;
}
parent
::
add
(
$element
);
if
(
$this
->
_backRefFieldName
)
{
if
(
$this
->
_backRefFieldName
and
$setBackRef
)
{
// Set back reference to owner
if
(
$this
->
_association
->
isOneToMany
())
{
// OneToMany
...
...
@@ -219,7 +216,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
// ManyToMany
$otherCollection
=
$this
->
_typeClass
->
reflFields
[
$this
->
_backRefFieldName
]
->
getValue
(
$element
);
$otherCollection
->
hydrateAdd
(
$this
->
_owner
);
$otherCollection
->
hydrateAdd
(
$this
->
_owner
,
false
);
}
}
}
...
...
@@ -242,6 +239,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
private
function
_initialize
()
{
if
(
!
$this
->
_initialized
)
{
parent
::
clear
();
$this
->
_association
->
load
(
$this
->
_owner
,
$this
,
$this
->
_em
);
$this
->
_initialized
=
true
;
}
...
...
tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php
View file @
82c41668
...
...
@@ -134,7 +134,7 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
$categories
=
$firstProduct
->
getCategories
();
$firstCategoryProducts
=
$categories
[
0
]
->
getProducts
();
$secondCategoryProducts
=
$categories
[
1
]
->
getProducts
();
$this
->
assertEquals
(
2
,
count
(
$firstCategoryProducts
));
$this
->
assertEquals
(
2
,
count
(
$secondCategoryProducts
));
...
...
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