Commit 59575186 authored by Fabien Potencier's avatar Fabien Potencier

feature #1200 Allowing the use of both objects and arrays for the register() (mivanov93)

This PR was submitted for the 1.3 branch but it was merged into the 2.0.x-dev branch instead (closes #1200).

Discussion
----------

Allowing the use of both objects and arrays for the register()

Sometimes we may like to use objects for lazy loading and whatsoever and since PHP has the Traversable interface, that should be perfectly fine.

Commits
-------

9ac0fd70 Allowing the use of both objects and arrays for the register()
parents 19de0cd2 9ac0fd70
...@@ -22,7 +22,7 @@ Changelog ...@@ -22,7 +22,7 @@ Changelog
1.3.1 (2015-XX-XX) 1.3.1 (2015-XX-XX)
------------------ ------------------
* n/a * fixed session logout handler when a firewall is stateless
1.3.0 (2015-06-05) 1.3.0 (2015-06-05)
------------------ ------------------
......
...@@ -293,7 +293,7 @@ pattern:: ...@@ -293,7 +293,7 @@ pattern::
'secured' => array( 'secured' => array(
'pattern' => '^/admin/', 'pattern' => '^/admin/',
'form' => array('login_path' => '/login', 'check_path' => '/admin/login_check'), 'form' => array('login_path' => '/login', 'check_path' => '/admin/login_check'),
'logout' => array('logout_path' => '/admin/logout'), 'logout' => array('logout_path' => '/admin/logout', 'invalidate_session' => true),
// ... // ...
), ),
......
...@@ -121,11 +121,11 @@ class Application extends Container implements HttpKernelInterface, TerminableIn ...@@ -121,11 +121,11 @@ class Application extends Container implements HttpKernelInterface, TerminableIn
* Registers a service provider. * Registers a service provider.
* *
* @param ServiceProviderInterface $provider A ServiceProviderInterface instance * @param ServiceProviderInterface $provider A ServiceProviderInterface instance
* @param array $values An array of values that customizes the provider * @param array|Traversable $values An array or a Traversable of values that customizes the provider
* *
* @return Application * @return Application
*/ */
public function register(ServiceProviderInterface $provider, array $values = array()) public function register(ServiceProviderInterface $provider, $values = array())
{ {
$this->providers[] = $provider; $this->providers[] = $provider;
......
...@@ -233,6 +233,8 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener ...@@ -233,6 +233,8 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener
throw new \LogicException(sprintf('The "%s" authentication entry is not registered.', $type)); throw new \LogicException(sprintf('The "%s" authentication entry is not registered.', $type));
} }
$options['stateless'] = $stateless;
list($providerId, $listenerId, $entryPointId, $position) = $app['security.authentication_listener.factory.'.$type]($name, $options); list($providerId, $listenerId, $entryPointId, $position) = $app['security.authentication_listener.factory.'.$type]($name, $options);
if (null !== $entryPointId) { if (null !== $entryPointId) {
...@@ -504,7 +506,10 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener ...@@ -504,7 +506,10 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener
isset($options['with_csrf']) && $options['with_csrf'] && isset($app['form.csrf_provider']) ? $app['form.csrf_provider'] : null isset($options['with_csrf']) && $options['with_csrf'] && isset($app['form.csrf_provider']) ? $app['form.csrf_provider'] : null
); );
$invalidateSession = isset($options['invalidate_session']) ? $options['invalidate_session'] : true;
if (true === $invalidateSession && false === $options['stateless']) {
$listener->addHandler(new SessionLogoutHandler()); $listener->addHandler(new SessionLogoutHandler());
}
return $listener; return $listener;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment