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
51987764
Commit
51987764
authored
Sep 11, 2009
by
guilhermeblanco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Finished implementation for Association Mappings
parent
de67ffa1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
2 deletions
+48
-2
YamlExporter.php
lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php
+48
-2
No files found.
lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php
View file @
51987764
...
...
@@ -22,7 +22,10 @@
namespace
Doctrine\ORM\Tools\Export\Driver
;
use
Doctrine\ORM\Mapping\ClassMetadata
;
use
Doctrine\ORM\Mapping\ClassMetadata
,
Doctrine\ORM\Mapping\OneToOneMapping
,
Doctrine\ORM\Mapping\OneToManyMapping
,
Doctrine\ORM\Mapping\ManyToManyMapping
;
/**
* ClassMetadata exporter for Doctrine YAML mapping files
...
...
@@ -82,13 +85,56 @@ class YamlExporter extends AbstractExporter
if
(
$idGeneratorType
=
$metadata
->
getIdGeneratorType
())
{
$id
[
$metadata
->
getSingleIdentifierFieldName
()][
'generator'
][
'strategy'
]
=
$idGeneratorType
;
}
$array
[
'id'
]
=
$id
;
$array
[
'fields'
]
=
$fields
;
$associations
=
array
();
foreach
(
$metadata
->
associationMappings
as
$name
=>
$associationMapping
)
{
// TODO: build array of association mappings
$associationMappingArray
=
array
(
'fieldName'
=>
$associationMapping
->
sourceFieldName
,
'sourceEntity'
=>
$associationMapping
->
sourceEntityName
,
'targetEntity'
=>
$associationMapping
->
targetEntityName
,
'optional'
=>
$associationMapping
->
isOptional
,
'cascades'
=>
array
(
'remove'
=>
$associationMapping
->
isCascadeRemove
,
'persist'
=>
$associationMapping
->
isCascadePersist
,
'refresh'
=>
$associationMapping
->
isCascadeRefresh
,
'merge'
=>
$associationMapping
->
isCascadeMerge
,
'detach'
=>
$associationMapping
->
isCascadeDetach
,
),
);
if
(
$associationMapping
instanceof
OneToOneMapping
)
{
// TODO: We may need to re-include the quotes if quote = true in names of joinColumns
$oneToOneMappingArray
=
array
(
'mappedBy'
=>
$associationMapping
->
mappedByFieldName
,
'joinColumns'
=>
$associationMapping
->
joinColumns
,
'orphanRemoval'
=>
$associationMapping
->
orphanRemoval
,
);
$associationMappingArray
=
array_merge
(
$associationMappingArray
,
$oneToOneMappingArray
);
}
else
if
(
$associationMapping
instanceof
OneToManyMapping
)
{
$oneToManyMappingArray
=
array
(
'mappedBy'
=>
$associationMapping
->
mappedByFieldName
,
'orphanRemoval'
=>
$associationMapping
->
orphanRemoval
,
);
$associationMappingArray
=
array_merge
(
$associationMappingArray
,
$oneToManyMappingArray
);
}
else
if
(
$associationMapping
instanceof
ManyToManyMapping
)
{
// TODO: We may need to re-include the quotes if quote = true in name of joinTable
$manyToManyMappingArray
=
array
(
'joinTable'
=>
$associationMapping
->
joinTable
,
);
$associationMappingArray
=
array_merge
(
$associationMappingArray
,
$manyToManyMappingArray
);
}
$associations
[
$name
]
=
$associationMappingArray
;
}
$array
[
'associations'
]
=
$associations
;
return
\sfYaml
::
dump
(
array
(
$metadata
->
name
=>
$array
),
10
);
}
}
\ 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