Skip to content

Instantly share code, notes, and snippets.

@doctrinebot
Created December 13, 2015 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doctrinebot/359f27d0bca83a98357d to your computer and use it in GitHub Desktop.
Save doctrinebot/359f27d0bca83a98357d to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-73 - https://github.com/doctrine/doctrine2/issues/5242
Index: tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php
===================================================================
--- tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php (revision 6683)
+++ tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php (working copy)
@@ -43,7 +43,6 @@
/**
* @Entity
- * @HasLifecycleCallbacks
* @Table(name="lc_cb_test_entity")
*/
class LifecycleCallbackTestEntity
@@ -82,4 +81,4 @@
public function doStuffOnPreUpdate() {
$this->value = 'changed from preUpdate callback!';
}
-}
\ No newline at end of file
+}
Index: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
===================================================================
--- lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php (revision 6683)
+++ lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php (working copy)
@@ -280,40 +280,38 @@
}
}
- // Evaluate HasLifecycleCallbacks annotation
- if (isset($classAnnotations['Doctrine\ORM\Mapping\HasLifecycleCallbacks'])) {
- foreach ($class->getMethods() as $method) {
- if ($method->isPublic()) {
- $annotations = $this->_reader->getMethodAnnotations($method);
-
- if (isset($annotations['Doctrine\ORM\Mapping\PrePersist'])) {
- $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::prePersist);
- }
-
- if (isset($annotations['Doctrine\ORM\Mapping\PostPersist'])) {
- $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postPersist);
- }
-
- if (isset($annotations['Doctrine\ORM\Mapping\PreUpdate'])) {
- $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preUpdate);
- }
-
- if (isset($annotations['Doctrine\ORM\Mapping\PostUpdate'])) {
- $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postUpdate);
- }
-
- if (isset($annotations['Doctrine\ORM\Mapping\PreRemove'])) {
- $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preRemove);
- }
-
- if (isset($annotations['Doctrine\ORM\Mapping\PostRemove'])) {
- $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postRemove);
- }
-
- if (isset($annotations['Doctrine\ORM\Mapping\PostLoad'])) {
- $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postLoad);
- }
+ // Evaluate Lifecycle Callbacks
+ foreach ($class->getMethods() as $method) {
+ if ($method->isPublic()) {
+ $annotations = $this->_reader->getMethodAnnotations($method);
+
+ if (isset($annotations['Doctrine\ORM\Mapping\PrePersist'])) {
+ $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::prePersist);
}
+
+ if (isset($annotations['Doctrine\ORM\Mapping\PostPersist'])) {
+ $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postPersist);
+ }
+
+ if (isset($annotations['Doctrine\ORM\Mapping\PreUpdate'])) {
+ $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preUpdate);
+ }
+
+ if (isset($annotations['Doctrine\ORM\Mapping\PostUpdate'])) {
+ $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postUpdate);
+ }
+
+ if (isset($annotations['Doctrine\ORM\Mapping\PreRemove'])) {
+ $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preRemove);
+ }
+
+ if (isset($annotations['Doctrine\ORM\Mapping\PostRemove'])) {
+ $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postRemove);
+ }
+
+ if (isset($annotations['Doctrine\ORM\Mapping\PostLoad'])) {
+ $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postLoad);
+ }
}
}
}
@@ -361,4 +359,4 @@
return array();
}
}
-}
\ No newline at end of file
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment