[SecurityBundle] Enhance FirewallContext::getListeners()

This commit is contained in:
Roland Franssen 2017-04-19 19:30:56 +02:00
parent df155dd5b4
commit ba650783f5
5 changed files with 19 additions and 11 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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;
}
}

View File

@ -124,7 +124,7 @@ class _FirewallMap
return array(array(), null);
}
return $context->getListeners();
return array($context->getListeners(), $context->getExceptionListener());
}
/**

View File

@ -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()