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
2c7ced23
Commit
2c7ced23
authored
Oct 05, 2007
by
gnat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow for both sides of a relationship to be generated from a one sided definition
parent
f50128c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
4 deletions
+41
-4
Schema.php
lib/Doctrine/Import/Schema.php
+41
-4
No files found.
lib/Doctrine/Import/Schema.php
View file @
2c7ced23
...
...
@@ -67,7 +67,7 @@ class Doctrine_Import_Schema
{
$builder
=
new
Doctrine_Import_Builder
();
$builder
->
setTargetPath
(
$directory
);
$builder
->
generateBaseClasses
(
tru
e
);
$builder
->
generateBaseClasses
(
fals
e
);
$schema
=
$this
->
buildSchema
(
$schema
,
$format
);
...
...
@@ -165,13 +165,13 @@ class Doctrine_Import_Schema
return
$build
;
}
public
function
buildRelationships
(
$array
)
public
function
buildRelationships
(
&
$array
)
{
foreach
(
$array
as
$name
=>
$properties
)
{
if
(
!
isset
(
$properties
[
'relations'
]))
{
continue
;
}
echo
"name:
$name
\n
"
;
$className
=
$properties
[
'className'
];
$relations
=
$properties
[
'relations'
];
...
...
@@ -180,7 +180,7 @@ class Doctrine_Import_Schema
$class
=
isset
(
$relation
[
'class'
])
?
$relation
[
'class'
]
:
$alias
;
$relation
[
'foreign'
]
=
isset
(
$relation
[
'foreign'
])
?
$relation
[
'foreign'
]
:
'id'
;
$relation
[
'alias'
]
=
$alias
;
$relation
[
'alias'
]
=
isset
(
$relation
[
'alias'
])
?
$relation
[
'alias'
]
:
$alias
;
$relation
[
'class'
]
=
$class
;
if
(
isset
(
$relation
[
'type'
])
&&
$relation
[
'type'
])
{
...
...
@@ -188,9 +188,46 @@ class Doctrine_Import_Schema
}
else
{
$relation
[
'type'
]
=
Doctrine_Relation
::
ONE
;
}
if
(
isset
(
$relation
[
'ftype'
])
&&
$relation
[
'ftype'
])
{
$relation
[
'ftype'
]
=
$relation
[
'ftype'
]
===
'one'
?
Doctrine_Relation
::
ONE
:
Doctrine_Relation
::
MANY
;
}
if
(
isset
(
$relation
[
'refClass'
])
&&
!
empty
(
$relation
[
'refClass'
])
&&
(
!
isset
(
$array
[
$relation
[
'refClass'
]][
'relations'
])
||
empty
(
$array
[
$relation
[
'refClass'
]][
'relations'
])))
{
$array
[
$relation
[
'refClass'
]][
'relations'
][
$className
]
=
array
(
'local'
=>
$relation
[
'local'
],
'foreign'
=>
$relation
[
'foreign'
],
'ignore'
=>
true
);
$array
[
$relation
[
'refClass'
]][
'relations'
][
$relation
[
'class'
]]
=
array
(
'local'
=>
$relation
[
'local'
],
'foreign'
=>
$relation
[
'foreign'
],
'ignore'
=>
true
);
if
(
isset
(
$relation
[
'foreignAlias'
]))
$array
[
$relation
[
'class'
]][
'relations'
][
$relation
[
'foreignAlias'
]]
=
array
(
'type'
=>
$relation
[
'type'
],
'local'
=>
$relation
[
'foreign'
],
'foreign'
=>
$relation
[
'local'
],
'refClass'
=>
$relation
[
'refClass'
],
'class'
=>
$className
);
}
$this
->
relations
[
$className
][
$alias
]
=
$relation
;
}
}
$this
->
fixRelationships
();
}
public
function
fixRelationships
()
{
// define both sides of the relationship
foreach
(
$this
->
relations
as
$className
=>
$relations
)
{
foreach
(
$relations
AS
$alias
=>
$relation
)
{
if
(
isset
(
$relation
[
'ignore'
])
&&
$relation
[
'ignore'
]
||
isset
(
$relation
[
'refClass'
]))
continue
;
$newRelation
=
array
();
$newRelation
[
'foreign'
]
=
$relation
[
'local'
];
$newRelation
[
'local'
]
=
$relation
[
'foreign'
];
$newRelation
[
'class'
]
=
$className
;
$newRelation
[
'alias'
]
=
isset
(
$relation
[
'foreignAlias'
])
?
$relation
[
'foreignAlias'
]
:
$className
;
if
(
isset
(
$relation
[
'ftype'
]))
{
$newRelation
[
'type'
]
=
$relation
[
'ftype'
];
}
else
{
$newRelation
[
'type'
]
=
$relation
[
'type'
]
===
Doctrine_Relation
::
ONE
?
Doctrine_Relation
::
MANY
:
Doctrine_Relation
::
ONE
;
}
$this
->
relations
[
$relation
[
'class'
]][
$className
]
=
$newRelation
;
}
}
}
}
\ 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