diff --git a/doctrine-mapping.xsd b/doctrine-mapping.xsd
index 1d97fd688..243bfcd5b 100644
--- a/doctrine-mapping.xsd
+++ b/doctrine-mapping.xsd
@@ -51,6 +51,7 @@
+
diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
index 3ddf70c86..30f664104 100644
--- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
+++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
@@ -435,14 +435,6 @@ class AnnotationDriver extends AbstractAnnotationDriver
}
}
}
-
- // Evaluate as lifecycle callback if the listener class is not given.
- if(empty($entityListenersAnnot->value)) {
- /* @var $method \Doctrine\ORM\Mapping\LifecycleCallback */
- foreach ($entityListenersAnnot->callbacks as $callback) {
- $metadata->addLifecycleCallback($callback->method, $callback->event);
- }
- }
}
// Evaluate @HasLifecycleCallbacks annotation
diff --git a/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php b/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php
index 9a5f33448..14abadb9e 100644
--- a/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php
+++ b/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php
@@ -64,5 +64,4 @@ require_once __DIR__.'/../AssociationOverride.php';
require_once __DIR__.'/../AssociationOverrides.php';
require_once __DIR__.'/../AttributeOverride.php';
require_once __DIR__.'/../AttributeOverrides.php';
-require_once __DIR__.'/../EntityListeners.php';
-require_once __DIR__.'/../LifecycleCallback.php';
+require_once __DIR__.'/../EntityListeners.php';
\ No newline at end of file
diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
index 11d579a35..625940d6d 100644
--- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
+++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
@@ -19,10 +19,10 @@
namespace Doctrine\ORM\Mapping\Driver;
-use SimpleXMLElement,
- Doctrine\Common\Persistence\Mapping\Driver\FileDriver,
- Doctrine\Common\Persistence\Mapping\ClassMetadata,
- Doctrine\ORM\Mapping\MappingException;
+use SimpleXMLElement;
+use Doctrine\Common\Persistence\Mapping\Driver\FileDriver;
+use Doctrine\Common\Persistence\Mapping\ClassMetadata;
+use Doctrine\ORM\Mapping\MappingException;
/**
* XmlDriver is a metadata driver that enables mapping through XML files.
@@ -560,28 +560,12 @@ class XmlDriver extends FileDriver
// Evaluate entity listener
if (isset($xmlRoot->{'entity-listeners'})) {
foreach ($xmlRoot->{'entity-listeners'}->{'entity-listener'} as $listenerElement) {
- $listeners = array();
-
foreach ($listenerElement as $callbackElement) {
$eventName = (string) $callbackElement['type'];
$methodName = (string) $callbackElement['method'];
+ $className = (string) $listenerElement['class'];
- $listeners[] = array($eventName, $methodName);
- }
-
- if (isset($listenerElement['class'])) {
- $className = (string) $listenerElement['class'];
-
- foreach ($listeners as $item) {
- $metadata->addEntityListener($item[0], $className, $item[1]);
- }
-
- continue;
- }
-
- // Evaluate as lifecycle callback if the listener class is not given.
- foreach ($listeners as $item) {
- $metadata->addLifecycleCallback($item[1], $item[0]);
+ $metadata->addEntityListener($eventName, $className, $methodName);
}
}
}
diff --git a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
index a4154871e..e53de341c 100644
--- a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
+++ b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
@@ -575,34 +575,12 @@ class YamlDriver extends FileDriver
// Evaluate entityListeners
if (isset($element['entityListeners'])) {
- foreach ($element['entityListeners'] as $entityListener) {
- $listeners = array();
- $className = null;
-
- if (isset($entityListener['class'])) {
- $className = $entityListener['class'];
-
- unset($entityListener['class']);
- }
-
+ foreach ($element['entityListeners'] as $className => $entityListener) {
foreach ($entityListener as $eventName => $callbackElement){
foreach ($callbackElement as $methodName){
- $listeners[] = array($eventName, $methodName);
+ $metadata->addEntityListener($eventName, $className, $methodName);
}
}
-
- if (null !== $className) {
- foreach ($listeners as $item){
- $metadata->addEntityListener($item[0], $className, $item[1]);
- }
-
- continue;
- }
-
- // Evaluate as lifecycle callback if the listener class is not given.
- foreach ($listeners as $item){
- $metadata->addLifecycleCallback($item[1], $item[0]);
- }
}
}
}
diff --git a/lib/Doctrine/ORM/Mapping/EntityListeners.php b/lib/Doctrine/ORM/Mapping/EntityListeners.php
index fda08c4c9..d9478a497 100644
--- a/lib/Doctrine/ORM/Mapping/EntityListeners.php
+++ b/lib/Doctrine/ORM/Mapping/EntityListeners.php
@@ -38,11 +38,4 @@ final class EntityListeners implements Annotation
* @var array
*/
public $value = array();
-
- /**
- * Specifies the entity lifecycle callbacks.
- *
- * @var array<\Doctrine\ORM\Mapping\LifecycleCallback>
- */
- public $callbacks = array();
}
\ No newline at end of file
diff --git a/lib/Doctrine/ORM/Mapping/LifecycleCallback.php b/lib/Doctrine/ORM/Mapping/LifecycleCallback.php
deleted file mode 100644
index 0b1b39585..000000000
--- a/lib/Doctrine/ORM/Mapping/LifecycleCallback.php
+++ /dev/null
@@ -1,41 +0,0 @@
-.
- */
-
-namespace Doctrine\ORM\Mapping;
-
-/**
- * @author Fabio B. Silva
- * @since 2.4
- *
- * @Annotation
- * @Target("ANNOTATION")
- */
-final class LifecycleCallback implements Annotation
-{
- /**
- * @var string
- */
- public $event;
-
- /**
- * @var string
- */
- public $method;
-}
\ No newline at end of file
diff --git a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php
index 16394fd87..7d22275b2 100644
--- a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php
+++ b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php
@@ -59,9 +59,6 @@ namespace Doctrine\Tests\Models\CMS;
* )
* })
*
- * @EntityListeners(callbacks = {
- * @LifecycleCallback(\Doctrine\ORM\Events::prePersist, method = "prePersistHandler")
- * })
*/
class CmsAddress
{
@@ -129,11 +126,6 @@ class CmsAddress
}
}
- public function prePersistHandler($event)
- {
- $this->prePersistHandlerCalls[] = $event;
- }
-
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{
$metadata->setPrimaryTable(array(
@@ -162,8 +154,6 @@ class CmsAddress
'joinColumns' => array(array('referencedColumnName' => 'id'))
));
- $metadata->addLifecycleCallback('prePersistHandler', 'prePersist');
-
$metadata->addNamedNativeQuery(array (
'name' => 'find-all',
'query' => 'SELECT id, country, city FROM cms_addresses',
@@ -182,7 +172,6 @@ class CmsAddress
'resultSetMapping' => 'mapping-count',
));
-
$metadata->addSqlResultSetMapping(array (
'name' => 'mapping-find-all',
'columns' => array(),
diff --git a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php
index 151da181b..c19675b6d 100644
--- a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php
+++ b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php
@@ -11,7 +11,6 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
parent::setUp();
try {
$this->_schemaTool->createSchema(array(
- $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\EntityListenersLifecycleCallback'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackEventArgEntity'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestUser'),
@@ -255,29 +254,6 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
$e->calls['postRemoveHandler']
);
}
- /**
- * @group DDC-1955
- */
- public function testEventListenersLifecycleCallback()
- {
- $e = new EntityListenersLifecycleCallback;
- $e->value = 'foo';
-
- $this->_em->persist($e);
- $this->_em->flush();
-
- $this->assertCount(2, $e->calls);
-
- $this->assertInstanceOf(
- 'Doctrine\ORM\Event\LifecycleEventArgs',
- $e->calls['prePersistHandler']
- );
-
- $this->assertInstanceOf(
- 'Doctrine\ORM\Event\LifecycleEventArgs',
- $e->calls['postPersistHandler']
- );
- }
}
/** @Entity @HasLifecycleCallbacks */
@@ -406,35 +382,6 @@ class LifecycleListenerPreUpdate
}
}
-
-/**
- * @Entity
- * @EntityListeners(callbacks = {
- * @LifecycleCallback(\Doctrine\ORM\Events::prePersist, method = "prePersistHandler"),
- * @LifecycleCallback(\Doctrine\ORM\Events::postPersist, method = "postPersistHandler"),
- * })
- */
-class EntityListenersLifecycleCallback
-{
- /** @Id @Column(type="integer") @GeneratedValue */
- public $id;
-
- /** @Column() */
- public $value;
-
- public $calls = array();
-
- public function prePersistHandler($event)
- {
- $this->calls[__FUNCTION__] = $event;
- }
-
- public function postPersistHandler(\Doctrine\ORM\Event\LifecycleEventArgs $event)
- {
- $this->calls[__FUNCTION__] = $event;
- }
-}
-
/** @Entity @HasLifecycleCallbacks */
class LifecycleCallbackEventArgEntity
{
diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php
index 41df5127f..55c9d6ba8 100644
--- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php
+++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php
@@ -856,21 +856,6 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
$this->assertEmpty($contractListener->postPersistCalls);
}
-
- /**
- * @group DDC-1955
- */
- public function testEventListenersLifecycleCallback()
- {
- $em = $this->_getTestEntityManager();
- $factory = $this->createClassMetadataFactory($em);
- $metadata = $factory->getMetadataFor('Doctrine\Tests\Models\CMS\CmsAddress');
-
- $this->assertArrayHasKey('prePersist', $metadata->lifecycleCallbacks);
- $this->assertCount(1, $metadata->lifecycleCallbacks['prePersist']);
- $this->assertEquals('prePersistHandler', $metadata->lifecycleCallbacks['prePersist'][0]);
- }
-
}
/**
diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml
index 9df9e9ae5..0af5facda 100644
--- a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml
+++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml
@@ -21,12 +21,6 @@
-
-
-
-
-
-
diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.yml
index cbff49615..696627c3c 100644
--- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.yml
+++ b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.yml
@@ -14,10 +14,6 @@ Doctrine\Tests\Models\CMS\CmsAddress:
resultSetMapping: mapping-count
query: SELECT COUNT(*) AS count FROM cms_addresses
- entityListeners:
- listener[0]:
- prePersist: [prePersistHandler]
-
sqlResultSetMappings:
mapping-find-all:
entityResult:
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
index e738569e5..03b9d3bed 100644
--- 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
@@ -8,8 +8,7 @@ Doctrine\Tests\Models\Company\CompanyContract:
flexultra: CompanyFlexUltraContract
entityListeners:
- listener[0]:
- class : CompanyContractListener
+ CompanyContractListener:
preFlush: [preFlushHandler]
postLoad: [postLoadHandler]
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
index a72e5de38..26ce8f3d5 100644
--- 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
@@ -2,8 +2,7 @@ Doctrine\Tests\Models\Company\CompanyFlexUltraContract:
type: entity
entityListeners:
- listener[0]:
- class : CompanyContractListener
+ CompanyContractListener:
preFlush: [preFlushHandler]
postLoad: [postLoadHandler]
@@ -17,8 +16,7 @@ Doctrine\Tests\Models\Company\CompanyFlexUltraContract:
postRemove: [postRemoveHandler]
preRemove: [preRemoveHandler]
- listener[1]:
- class : CompanyFlexUltraContractListener
+ CompanyFlexUltraContractListener:
prePersist: [prePersistHandler1, prePersistHandler2]