diff --git a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php index 50e51ed05..e0af987e3 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php @@ -572,6 +572,17 @@ class YamlDriver extends FileDriver } } } + + // Evaluate entityListeners + if (isset($element['entityListeners'])) { + foreach ($element['entityListeners'] as $className => $entityListener) { + foreach ($entityListener as $eventName => $callbackElement){ + foreach ($callbackElement as $methodName){ + $metadata->addEntityListener($eventName, $className, $methodName); + } + } + } + } } /** diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php index 5c6e04a69..a03434b58 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -759,7 +759,8 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase public function testEntityListeners() { if ( ! ($this instanceof AnnotationDriverTest) - && ! ($this instanceof XmlMappingDriverTest)) { + && ! ($this instanceof XmlMappingDriverTest) + && ! ($this instanceof YamlMappingDriverTest)) { $this->markTestIncomplete(); } @@ -818,7 +819,8 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase public function testCallEntityListeners() { if ( ! ($this instanceof AnnotationDriverTest) - && ! ($this instanceof XmlMappingDriverTest)) { + && ! ($this instanceof XmlMappingDriverTest) + && ! ($this instanceof YamlMappingDriverTest)) { $this->markTestIncomplete(); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyContract.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyContract.dcm.xml index 990b519b6..c4fc7adc8 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyContract.dcm.xml +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyContract.dcm.xml @@ -21,7 +21,7 @@ - + diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.xml index 8b0075367..f699c313c 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.xml +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.xml @@ -15,7 +15,7 @@ - + diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyContract.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyContract.dcm.yml new file mode 100644 index 000000000..c4e3f3026 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyContract.dcm.yml @@ -0,0 +1,30 @@ +Doctrine\Tests\Models\Company\CompanyContract: + type: entity + table: company_contracts + inheritanceType: SINGLE_TABLE + discriminatorMap: + fix: CompanyFixContract + flexible: CompanyFlexContract + flexultra: CompanyFlexUltraContract + entityListeners: + ContractSubscriber: + preFlush: [preFlushHandler] + postLoad: [postLoadHandler] + + postPersist: [postPersistHandler] + prePersist: [prePersistHandler] + + postUpdate: [postUpdateHandler] + preUpdate: [preUpdateHandler] + + postRemove: [postRemoveHandler] + preRemove: [preRemoveHandler] + + id: + id: + type: integer + generator: + strategy: AUTO + fields: + completed: + type: boolean \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFixContract.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFixContract.dcm.yml new file mode 100644 index 000000000..83d0c75be --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFixContract.dcm.yml @@ -0,0 +1,5 @@ +Doctrine\Tests\Models\Company\CompanyFixContract: + type: entity + fields: + fixPrice: + type: integer \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFlexContract.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFlexContract.dcm.yml new file mode 100644 index 000000000..ef1d26306 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFlexContract.dcm.yml @@ -0,0 +1,7 @@ +Doctrine\Tests\Models\Company\CompanyFlexContract: + type: entity + fields: + hoursWorked: + type: integer + pricePerHour: + type: integer \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.yml new file mode 100644 index 000000000..48a42e649 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.yml @@ -0,0 +1,22 @@ +Doctrine\Tests\Models\Company\CompanyFlexUltraContract: + type: entity + entityListeners: + ContractSubscriber: + preFlush: [preFlushHandler] + postLoad: [postLoadHandler] + + postPersist: [postPersistHandler] + prePersist: [prePersistHandler] + + postUpdate: [postUpdateHandler] + preUpdate: [preUpdateHandler] + + postRemove: [postRemoveHandler] + preRemove: [preRemoveHandler] + + FlexUltraContractSubscriber: + prePersist: [prePersistHandler1, prePersistHandler2] + + fields: + maxPrice: + type: integer \ No newline at end of file