symfony/symfony — pull request #10417 by ogizanagi (2014-03-11 15:28:36+00:00)
Title: [AbstractFactory] [Factory] [SecurityBundle] fix options & providerKey n...

...ot passed to custom success_handler & failure_handler

When defining a custom success_handle or failure_handler, no arguments where passed to the constructor. This patch assume that a custom handler will inherit the default one, so we could retrieved the firewall properties, and if needed, add more arguments.

| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | yes
| Deprecations? | no
| Tests pass? | Don't know
| Fixed tickets | #9272
| License | MIT

Allow options & providerKey from firewall configuration to be passed to custom handlers.

This pull request reference this other one : https://github.com/symfony/symfony/pull/9279 but for the 2.2 branch and rebased.

As discussed in the previous pull request, this could be seen as a BC break because someone could have implemented a handler which doesn't have a constructor with the same signature as the default one, or doesn't inherit the default one.

Maybe ```AuthenticationSuccessHandlerInterface``` should define the ```public function setOptions(array $options)``` and ```public function setProviderKey($providerKey)``` methods.
Then, we could use the ```addMethodCall('setOptions', array($options));``` from the DefinitionDecorator, instead of ```replaceArgument```.

Anyway, ```public function setProviderKey($providerKey)``` is currently used by the ```createAuthenticationSuccessHandler``` although the ```AuthenticationSuccessHandlerInterface``` doesn't describe it:

```php

protected function createAuthenticationSuccessHandler($container, $id, $config)
{
[...]
$successHandler->replaceArgument(1, array_intersect_key($config, $this->defaultSuccessHandlerOptions));
$successHandler->addMethodCall('setProviderKey', array($id));
[...]
}
```