Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fab0985

Browse files
committed
[#5828] Return early
1 parent a392041 commit fab0985

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cookbook/doctrine/event_listeners_subscribers.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,13 @@ a ``postPersist`` method, which will be called when the event is dispatched::
136136
{
137137
$entity = $args->getEntity();
138138

139-
// perhaps you only want to act on some "Product" entity
140-
if ($entity instanceof Product) {
141-
$entityManager = $args->getEntityManager();
142-
// ... do something with the Product
139+
// only act on some "Product" entity
140+
if (!$entity instanceof Product) {
141+
return;
143142
}
143+
144+
$entityManager = $args->getEntityManager();
145+
// ... do something with the Product
144146
}
145147
}
146148

0 commit comments

Comments
 (0)