Commit fd89892c authored by jwage's avatar jwage

[2.0] Updating YAML and XML drivers to be synchronized with Annotations driver.

parent 27356225
......@@ -33,7 +33,7 @@
</xs:sequence>
</xs:complexType>
<xs:simpleType name="lifecycle-callback-type">
<xs:simpleType name="lifecycle-listener-type">
<xs:restriction base="xs:token">
<xs:enumeration value="prePersist"/>
<xs:enumeration value="postPersist"/>
......@@ -45,14 +45,14 @@
</xs:restriction>
</xs:simpleType>
<xs:complexType name="lifecycle-callback">
<xs:attribute name="type" type="orm:lifecycle-callback-type" use="required" />
<xs:complexType name="lifecycle-listener">
<xs:attribute name="type" type="orm:lifecycle-listener-type" use="required" />
<xs:attribute name="method" type="xs:NMTOKEN" use="required" />
</xs:complexType>
<xs:complexType name="lifecycle-callbacks">
<xs:complexType name="lifecycle-listener">
<xs:sequence>
<xs:element name="lifecycle-callback" type="orm:lifecycle-callback" minOccurs="1" maxOccurs="unbounded" />
<xs:element name="lifecycle-listener" type="orm:lifecycle-listener" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
......
......@@ -112,12 +112,6 @@ class AnnotationDriver implements Driver
$metadata->setDiscriminatorMap($discrMapAnnot->value);
}
// Evaluate DoctrineSubClasses annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\SubClasses'])) {
$subClassesAnnot = $classAnnotations['Doctrine\ORM\Mapping\SubClasses'];
$metadata->setSubclasses($subClassesAnnot->value);
}
// Evaluate DoctrineChangeTrackingPolicy annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\ChangeTrackingPolicy'])) {
$changeTrackingAnnot = $classAnnotations['Doctrine\ORM\Mapping\ChangeTrackingPolicy'];
......
......@@ -97,6 +97,9 @@ class MappingDriverTest extends \Doctrine\Tests\OrmTestCase
$this->assertTrue($class->associationMappings['groups'] instanceof \Doctrine\ORM\Mapping\ManyToManyMapping);
$this->assertTrue(isset($class->associationMappings['groups']));
$this->assertTrue($class->associationMappings['groups']->isOwningSide);
$this->assertEquals(count($class->lifecycleCallbacks), 2);
$this->assertEquals($class->lifecycleCallbacks['prePersist'][0], 'doStuffOnPrePersist');
$this->assertEquals($class->lifecycleCallbacks['postPersist'][0], 'doStuffOnPostPersist');
}
}
......@@ -108,4 +111,13 @@ class User {
private $groups;
// ... rest of code omitted, irrelevant for the mapping tests
public function doStuffOnPrePersist()
{
}
public function doStuffOnPostPersist()
{
}
}
\ No newline at end of file
......@@ -7,10 +7,9 @@
<entity name="Doctrine\Tests\ORM\Mapping\User" table="cms_users">
<lifecycle-callbacks>
<lifecycle-callback type="prePersist" method="onPrePersist" />
</lifecycle-callbacks>
<lifecycle-listener method="doStuffOnPrePersist" type="prePersist" />
<lifecycle-listener method="doStuffOnPostPersist" type="postPersist" />
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>
......
......@@ -31,4 +31,7 @@ Doctrine\Tests\ORM\Mapping\User:
referencedColumnName: id
inverseJoinColumns:
group_id:
referencedColumnName: id
\ No newline at end of file
referencedColumnName: id
lifecycleListeners:
doStuffOnPrePersist: prePersist
doStuffOnPostPersist: postPersist
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment