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
70addc55
Commit
70addc55
authored
Nov 29, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes to model building so it does not generate duplicate relations.
parent
13a79c45
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
2 deletions
+33
-2
Schema.php
lib/Doctrine/Import/Schema.php
+33
-2
No files found.
lib/Doctrine/Import/Schema.php
View file @
70addc55
...
...
@@ -212,7 +212,24 @@ class Doctrine_Import_Schema
*/
public
function
getRelations
(
$properties
)
{
return
isset
(
$this
->
_relations
[
$properties
[
'className'
]])
?
$this
->
_relations
[
$properties
[
'className'
]]
:
array
();
$allRelations
=
isset
(
$this
->
_relations
[
$properties
[
'className'
]])
?
$this
->
_relations
[
$properties
[
'className'
]]
:
array
();
// This is for checking for duplicates between alias-relations and a auto-generated relations to ensure the result set of unique relations
$existingRelations
=
array
();
$uniqueRelations
=
array
();
foreach
(
$allRelations
as
$relation
)
{
if
(
!
in_array
(
$relation
[
'key'
],
$existingRelations
))
{
$existingRelations
[]
=
$relation
[
'key'
];
$uniqueRelations
=
array_merge
(
$uniqueRelations
,
array
(
$relation
[
'alias'
]
=>
$relation
));
}
else
{
// check to see if this relationship is not autogenerated, if it's not, then the user must have explicitly declared it
if
(
!
isset
(
$relation
[
'autogenerated'
])
||
$relation
[
'autogenerated'
]
!=
true
)
{
$uniqueRelations
=
array_merge
(
$uniqueRelations
,
array
(
$relation
[
'alias'
]
=>
$relation
));
}
}
}
return
$uniqueRelations
;
}
/**
...
...
@@ -376,7 +393,7 @@ class Doctrine_Import_Schema
* @param string $array
* @return void
*/
protected
function
_buildRelationships
(
&
$array
)
protected
function
_buildRelationships
(
$array
)
{
foreach
(
$array
as
$name
=>
$properties
)
{
if
(
!
isset
(
$properties
[
'relations'
]))
{
...
...
@@ -415,6 +432,8 @@ class Doctrine_Import_Schema
$relation
[
'foreignType'
]
=
$relation
[
'foreignType'
]
===
'one'
?
Doctrine_Relation
::
ONE
:
Doctrine_Relation
::
MANY
;
}
$relation
[
'key'
]
=
$this
->
_buildUniqueRelationKey
(
$relation
);
$this
->
_relations
[
$className
][
$alias
]
=
$relation
;
}
}
...
...
@@ -456,9 +475,21 @@ class Doctrine_Import_Schema
}
if
(
!
isset
(
$this
->
_relations
[
$relation
[
'class'
]][
$newRelation
[
'alias'
]]))
{
$newRelation
[
'key'
]
=
$this
->
_buildUniqueRelationKey
(
$newRelation
);
$this
->
_relations
[
$relation
[
'class'
]][
$newRelation
[
'alias'
]]
=
$newRelation
;
}
}
}
}
/**
* _buildUniqueRelationKey
*
* @param string $relation
* @return void
*/
protected
function
_buildUniqueRelationKey
(
$relation
)
{
return
md5
(
$relation
[
'local'
]
.
$relation
[
'foreign'
]
.
$relation
[
'class'
]
.
(
isset
(
$relation
[
'refClass'
])
?
$relation
[
'refClass'
]
:
null
));
}
}
\ No newline at end of file
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