[SecurityBundle] Enhance FirewallContext::getListeners()
This commit is contained in:
parent
df155dd5b4
commit
ba650783f5
@ -306,7 +306,7 @@ SecurityBundle
|
|||||||
--------------
|
--------------
|
||||||
|
|
||||||
* The `FirewallContext::getContext()` method has been deprecated and will be removed in 4.0.
|
* 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.
|
* The `FirewallMap::$map` and `$container` properties have been deprecated and will be removed in 4.0.
|
||||||
|
|
||||||
|
@ -428,7 +428,7 @@ Security
|
|||||||
SecurityBundle
|
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.
|
* The `FirewallMap::$map` and `$container` properties have been removed.
|
||||||
|
|
||||||
|
@ -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()
|
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()
|
public function getListeners()
|
||||||
{
|
{
|
||||||
return array($this->listeners, $this->exceptionListener);
|
return $this->listeners;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getExceptionListener()
|
||||||
|
{
|
||||||
|
return $this->exceptionListener;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ class _FirewallMap
|
|||||||
return array(array(), null);
|
return array(array(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $context->getListeners();
|
return array($context->getListeners(), $context->getExceptionListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,18 +32,21 @@ class FirewallContextTest extends TestCase
|
|||||||
|
|
||||||
$context = new FirewallContext($listeners, $exceptionListener, $config);
|
$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());
|
$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
|
* @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();
|
->getContext();
|
||||||
|
|
||||||
|
$this->assertEquals(array($listeners, $exceptionListener), $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getExceptionListenerMock()
|
private function getExceptionListenerMock()
|
||||||
|
Reference in New Issue
Block a user