symfony/symfony — Issue #3115: EventDispatcher::removeListener not working
Author: getme
Created: 2012-01-14 04:10:32+00:00
State: open

I have the following setup

```
services:
my.event_manager:
class: My\EventListener\EventManager
arguments: [@service_container]
tags:
- { name: kernel.event_listener, event: kernel.request }
```

```
class EventManager
{
/**
*
* @var ContainerInterface
*/
private $container;

public function __construct(ContainerInterface $container)
{
$this->container = $container;
}

public function onKernelRequest(GetResponseEvent $event)
{
$listener = new \My\EventListener\CustomerListener($this->container);
$this->container->get('event_dispatcher')->addListener('on_updated', array($listener, 'onUpdate'));
}
}
```

But in some controller actions I don't want to this event to be called so I did this:

```
$this->get('event_dispatcher')->removeListener('on_updated', 'onUpdate');
```

But the event is still processed, what I'm doing wrong?