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
cbd81333
Commit
cbd81333
authored
Feb 24, 2010
by
beberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] DDC-367 - Fixed Bug with <discriminator-map /> XML Driver Parsing
parent
a1a80938
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
2 deletions
+49
-2
XmlDriver.php
lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
+5
-1
XmlMappingDriverTest.php
tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php
+28
-1
Doctrine.Tests.ORM.Mapping.CTI.dcm.xml
...ts/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml
+16
-0
No files found.
lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
View file @
cbd81333
...
...
@@ -85,7 +85,11 @@ class XmlDriver extends AbstractFileDriver
// Evaluate <discriminator-map...>
if
(
isset
(
$xmlRoot
->
{
'discriminator-map'
}))
{
$metadata
->
setDiscriminatorMap
((
array
)
$xmlRoot
->
{
'discriminator-map'
});
$map
=
array
();
foreach
(
$xmlRoot
->
{
'discriminator-map'
}
->
{
'discriminator-mapping'
}
AS
$discrMapElement
)
{
$map
[(
string
)
$discrMapElement
[
'value'
]]
=
(
string
)
$discrMapElement
[
'class'
];
}
$metadata
->
setDiscriminatorMap
(
$map
);
}
// Evaluate <change-tracking-policy...>
...
...
tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php
View file @
cbd81333
...
...
@@ -14,4 +14,31 @@ class XmlMappingDriverTest extends AbstractMappingDriverTest
{
return
new
XmlDriver
(
__DIR__
.
DIRECTORY_SEPARATOR
.
'xml'
);
}
public
function
testClassTableInheritanceDiscriminatorMap
()
{
$className
=
'Doctrine\Tests\ORM\Mapping\CTI'
;
$mappingDriver
=
$this
->
_loadDriver
();
$class
=
new
ClassMetadata
(
$className
);
$mappingDriver
->
loadMetadataForClass
(
$className
,
$class
);
$expectedMap
=
array
(
"foo"
=>
"Doctrine\Tests\ORM\Mapping\CTIFoo"
,
"bar"
=>
"Doctrine\Tests\ORM\Mapping\CTIBar"
,
"baz"
=>
"Doctrine\Tests\ORM\Mapping\CTIBaz"
,
);
$this
->
assertEquals
(
3
,
count
(
$class
->
discriminatorMap
));
$this
->
assertEquals
(
$expectedMap
,
$class
->
discriminatorMap
);
}
}
class
CTI
{
public
$id
;
}
class
CTIFoo
extends
CTI
{}
class
CTIBar
extends
CTI
{}
class
CTIBaz
extends
CTI
{}
\ No newline at end of file
tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml
0 → 100644
View file @
cbd81333
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping
xmlns=
"http://doctrine-project.org/schemas/orm/doctrine-mapping"
xsi=
"http://www.w3.org/2001/XMLSchema-instance"
schemaLocation=
"http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
>
<entity
name=
"Doctrine\Tests\ORM\Mapping\CTI"
>
<discriminiator-column
name=
"discr"
type=
"string"
length=
""
/>
<discriminator-map>
<discriminator-mapping
value=
"foo"
class=
"CTIFoo"
/>
<discriminator-mapping
value=
"bar"
class=
"CTIBar"
/>
<discriminator-mapping
value=
"baz"
class=
"CTIBaz"
/>
</discriminator-map>
<id
name=
"id"
type=
"integer"
column=
"id"
>
<generator
strategy=
"AUTO"
/>
</id>
</entity>
</doctrine-mapping>
\ 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