I want to use Doctrine Entity Listener with Symfony 2.4.
I've created a class:
<?php
namespace MyBundle\Listener\Entity;
use Doctrine\ORM\Event\LifecycleEventArgs;
use MyBundle\Entity\User;
class UserListener
{
public function postPersist(User $user, LifecycleEventArgs $event)
{
}
}
I've added mapping information:
<?xml version="1.0" encoding="UTF-8" ?>
<doctrine-mapping>
<entity name="MyBundle\Entity\User">
...
<entity-listeners>
<entity-listener class="MyBundle\Listener\Entity\UserListener" />
</entity-listeners>
</entity>
</doctrine-mapping>
It's working OK. But how do I pass some services to this class? I want it to be integrated with the Symfony's service container and provided services.