diff --git a/UPGRADE-3.3.md b/UPGRADE-3.3.md index 47745b8ed7..ce939cb444 100644 --- a/UPGRADE-3.3.md +++ b/UPGRADE-3.3.md @@ -306,7 +306,7 @@ SecurityBundle -------------- * The `FirewallContext::getContext()` method has been deprecated and will be removed in 4.0. - Use the `getListeners()` method instead. + Use the `getListeners()` and/or `getExceptionListener()` method instead. * The `FirewallMap::$map` and `$container` properties have been deprecated and will be removed in 4.0. diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index ae350cc67b..c05fafdd72 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -428,7 +428,7 @@ Security SecurityBundle -------------- - * The `FirewallContext::getContext()` method has been removed, use the `getListeners()` method instead. + * The `FirewallContext::getContext()` method has been removed, use the `getListeners()` and/or `getExceptionListener()` method instead. * The `FirewallMap::$map` and `$container` properties have been removed. diff --git a/src/Symfony/Bundle/SecurityBundle/Security/FirewallContext.php b/src/Symfony/Bundle/SecurityBundle/Security/FirewallContext.php index beb1758a44..02f2739ed8 100644 --- a/src/Symfony/Bundle/SecurityBundle/Security/FirewallContext.php +++ b/src/Symfony/Bundle/SecurityBundle/Security/FirewallContext.php @@ -38,17 +38,22 @@ class FirewallContext } /** - * @deprecated since version 3.3, will be removed in 4.0. Use {@link getListeners()} instead. + * @deprecated since version 3.3, will be removed in 4.0. Use {@link getListeners()} and/or {@link getExceptionListener()} instead. */ public function getContext() { - @trigger_error(sprintf('Method %s() is deprecated since version 3.3 and will be removed in 4.0. Use %s::getListeners() instead.', __METHOD__, __CLASS__), E_USER_DEPRECATED); + @trigger_error(sprintf('Method %s() is deprecated since version 3.3 and will be removed in 4.0. Use %s::getListeners/getExceptionListener() instead.', __METHOD__, __CLASS__), E_USER_DEPRECATED); - return $this->getListeners(); + return array($this->getListeners(), $this->getExceptionListener()); } public function getListeners() { - return array($this->listeners, $this->exceptionListener); + return $this->listeners; + } + + public function getExceptionListener() + { + return $this->exceptionListener; } } diff --git a/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php b/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php index a511193aaa..55272ec304 100644 --- a/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php +++ b/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php @@ -124,7 +124,7 @@ class _FirewallMap return array(array(), null); } - return $context->getListeners(); + return array($context->getListeners(), $context->getExceptionListener()); } /** diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallContextTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallContextTest.php index 1bc6e44736..22be0fd081 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallContextTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallContextTest.php @@ -32,18 +32,21 @@ class FirewallContextTest extends TestCase $context = new FirewallContext($listeners, $exceptionListener, $config); - $this->assertEquals(array($listeners, $exceptionListener), $context->getListeners()); + $this->assertEquals($listeners, $context->getListeners()); + $this->assertEquals($exceptionListener, $context->getExceptionListener()); $this->assertEquals($config, $context->getConfig()); } /** - * @expectedDeprecation Method Symfony\Bundle\SecurityBundle\Security\FirewallContext::getContext() is deprecated since version 3.3 and will be removed in 4.0. Use Symfony\Bundle\SecurityBundle\Security\FirewallContext::getListeners() instead. + * @expectedDeprecation Method Symfony\Bundle\SecurityBundle\Security\FirewallContext::getContext() is deprecated since version 3.3 and will be removed in 4.0. Use Symfony\Bundle\SecurityBundle\Security\FirewallContext::getListeners/getExceptionListener() instead. * @group legacy */ - public function testGetContextTriggersDeprecation() + public function testGetContext() { - (new FirewallContext(array(), $this->getExceptionListenerMock(), new FirewallConfig('main', 'request_matcher', 'user_checker'))) + $context = (new FirewallContext($listeners = array(), $exceptionListener = $this->getExceptionListenerMock(), new FirewallConfig('main', 'request_matcher', 'user_checker'))) ->getContext(); + + $this->assertEquals(array($listeners, $exceptionListener), $context); } private function getExceptionListenerMock()