From 9de6f044a4e6a548cef86cb36f9905a4b4226418 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Fri, 23 Oct 2015 08:48:57 +0200 Subject: [PATCH] move the getEntityManager, only get it if needed --- cookbook/doctrine/event_listeners_subscribers.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cookbook/doctrine/event_listeners_subscribers.rst b/cookbook/doctrine/event_listeners_subscribers.rst index 93cbf3b4c1d..a5c7f563f30 100644 --- a/cookbook/doctrine/event_listeners_subscribers.rst +++ b/cookbook/doctrine/event_listeners_subscribers.rst @@ -135,10 +135,10 @@ a ``postPersist`` method, which will be called when the event is dispatched:: public function postPersist(LifecycleEventArgs $args) { $entity = $args->getEntity(); - $entityManager = $args->getEntityManager(); // perhaps you only want to act on some "Product" entity if ($entity instanceof Product) { + $entityManager = $args->getEntityManager(); // ... do something with the Product } } @@ -197,10 +197,10 @@ interface and have an event method for each event it subscribes to:: public function index(LifecycleEventArgs $args) { $entity = $args->getEntity(); - $entityManager = $args->getEntityManager(); // perhaps you only want to act on some "Product" entity if ($entity instanceof Product) { + $entityManager = $args->getEntityManager(); // ... do something with the Product } }