Let's say I have an entity described by this yaml mapping :
My\Entity:
type: entity
table: my_table
entityListeners:
My\Listener:
postLoad: [postLoad]
preFlush: [preFlush]
onFlush: [onFlush]
postFlush: [postFlush]
indexes:
# [...] Some foreign key indexes
id:
id:
type: smallint
nullable: false
options:
unsigned: true
id: true
column: my_id
generator:
strategy: IDENTITY
fields:
label:
type: string
length: 300
identifier:
type: string
nullable: true
length: 100
options:
fixed: false
description:
type: string
length: 255
nullable: true
active:
type: boolean
nullable: false
options:
default: '0'
# [...] Many associations
lifecycleCallbacks: { }
My listener, for test purpose, only makes var dumps for all the event
handler methods.
My edit action is quiet large and could be summarized as :
<?php
use Silex\Application;
class MyController
{
public function myEditAction(Application $app)
{
/**
* [...]
* Defines $em as \Doctrine\ORM\EntityManager
* Defines $form as \Symfony\Component\Form\FormBuilder
* A lot of form stuff and an entity definition
*/
if ($form->isSubmitted() && $form->isValid()) {
// There, I could add an onFlush event to
$em->getEventManager() to manage logs if the entity was changed (through
uow changeset)
$em->flush();
}
return new Symfony\Component\HttpFoundation\Response(200);
}
}
?>
I only see preFlush dump, neither onFlush nor postFlush seems to be handled
/ triggered at entity level.
Le jeudi 7 avril 2016 18:08:56 UTC+2, Marco Pivetta a écrit :
>
> Hi,
>
> Could you show some example code for this?
>
> Cheers,
>
> Marco Pivetta
>
> http://twitter.com/Ocramius
>
> http://ocramius.github.com/
>
> On 7 April 2016 at 18:07, dunaeth <[email protected] <javascript:>>
> wrote:
>
>> Hi,
>>
>> I'm tryin to register to onFlush events with entityListeners and I cannot
>> succeed. I'm able to register to preFlush events with the same
>> entityListener, I can also register to onFlush events with a global
>> eventManager eventListener, but neither onFlush nor postFlush events are
>> handled by entityListeners. Is it ever possible, was it added in some
>> doctrine version (mine is 2.5.4) or is there something that should be known
>> for this usage ?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "doctrine-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/doctrine-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.