8000 minor #8688 Update event_listeners_subscribers.rst (hamzahanafi11) · symfony/symfony-docs@41f099b · GitHub
[go: up one dir, main page]

Skip to content

Commit 41f099b

Browse files
committed
minor #8688 Update event_listeners_subscribers.rst (hamzahanafi11)
This PR was submitted for the 3.3 branch but it was merged into the 2.7 branch instead (closes #8688). Discussion ---------- Update event_listeners_subscribers.rst By using $args->getEntity() you can have access to the generated id (primary key) of the object Commits ------- 8363273 Update event_listeners_subscribers.rst d4e78c4 Update event_listeners_subscribers.rst
2 parents 0df2f8a + 8363273 commit 41f099b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

doctrine/event_listeners_subscribers.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,14 @@ a ``postPersist()`` method, which will be called when the event is dispatched::
131131
{
132132
public function postPersist(LifecycleEventArgs $args)
133133
{
134-
$object = $args->getObject();
134+
$entity = $args->getEntity();
135135

136136
// only act on some "Product" entity
137-
if (!$object instanceof Product) {
137+
if (!$entity instanceof Product) {
138138
return;
139139
}
140140

141-
$objectManager = $args->getObjectManager();
141+
$entityManager = $args->getEntityManager();
142142
// ... do something with the Product
143143
}
144144
}
@@ -195,7 +195,7 @@ interface and have an event method for each event it subscribes to::
195195

196196
public function index(LifecycleEventArgs $args)
197197
{
198-
$entity = $args->getObject();
198+
$entity = $args->getEntity();
199199

200200
// perhaps you only want to act on some "Product" entity
201201
if ($entity instanceof Product) {

0 commit comments

Comments
 (0)
0