Skip to content

Commit

Permalink
minor symfony#5828 move the getEntityManager, only get it if needed (…
Browse files Browse the repository at this point in the history
…OskarStark)

This PR was submitted for the 2.7 branch but it was merged into the 2.3 branch instead (closes symfony#5828).

Discussion
----------

move the getEntityManager, only get it if needed

if this will be merged, please be sure, that this is the correct branch!

Thank you

Commits
-------

1498140 move the getEntityManager, only get it if needed
  • Loading branch information
wouterj committed Nov 25, 2015
2 parents 10d2158 + 1498140 commit a392041
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cookbook/doctrine/event_listeners_subscribers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -191,10 +191,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
}
}
Expand Down

0 comments on commit a392041

Please sign in to comment.