Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe775e5

Browse files
committed
[SecurityBundle] Rename FirewallContext#getContext()
1 parent 13265ae commit fe775e5

File tree

5 files changed

+44
-8
lines changed

5 files changed

+44
-8
lines changed

UPGRADE-3.3.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
UPGRADE FROM 3.2 to 3.3
2+
=======================
3+
4+
SecurityBundle
5+
--------------
6+
7+
* The `FirewallContext::getContext()` method has been deprecated and will be removed in 4.0.
8+
Use the `getListeners()` method instead.

UPGRADE-4.0.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ FrameworkBundle
128128
`serializer.mapping.cache.apc` and `serializer.mapping.cache.doctrine.apc`
129129
have been removed. APCu should now be automatically used when available.
130130

131+
SecurityBundle
132+
--------------
133+
134+
* The `FirewallContext::getContext()` method has been removed, use the `getListeners()` method instead.
135+
131136
HttpFoundation
132137
---------------
133138

src/Symfony/Bundle/SecurityBundle/Security/FirewallContext.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,17 @@ public function getConfig()
3737
return $this->config;
3838
}
3939

40+
/**
41+
* @deprecated since version 3.3, will be removed in 4.0. Use {@link getListeners()} instead.
42+
*/
4043
public function getContext()
44+
{
45+
@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);
46+
47+
return $this->getListeners();
48+
}
49+
50+
public function getListeners()
4151
{
4252
return array($this->listeners, $this->exceptionListener);
4353
}

src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getListeners(Request $request)
4646
return array(array(), null);
4747
}
4848

49-
return $context->getContext();
49+
return $context->getListeners();
5050
}
5151

5252
/**

src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallContextTest.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ class FirewallContextTest extends \PHPUnit_Framework_TestCase
2121
public function testGetters()
2222
{
2323
$config = new FirewallConfig('main', 'user_checker', 'request_matcher');
24-
25-
$exceptionListener = $this
26-
->getMockBuilder(ExceptionListener::class)
27-
->disableOriginalConstructor()
28-
->getMock();
29-
24+
$exceptionListener = $this->getExceptionListenerMock();
3025
$listeners = array(
3126
$this
3227
->getMockBuilder(ListenerInterface::class)
@@ -36,7 +31,25 @@ public function testGetters()
3631

3732
$context = new FirewallContext($listeners, $exceptionListener, $config);
3833

39-
$this->assertEquals(array($listeners, $exceptionListener), $context->getContext());
34+
$this->assertEquals(array($listeners, $exceptionListener), $context->getListeners());
4035
$this->assertEquals($config, $context->getConfig());
4136
}
37+
38+
/**
39+
* @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.
40+
* @group legacy
41+
*/
42+
public function testGetContextTriggersDeprecation()
43+
{
44+
(new FirewallContext(array(), $this->getExceptionListenerMock(), new FirewallConfig('main', 'request_matcher', 'user_checker')))
45+
->getContext();
46+
}
47+
48+
private function getExceptionListenerMock()
49+
{
50+
return $this
51+
->getMockBuilder(ExceptionListener::class)
52+
->disableOriginalConstructor()
53+
->getMock();
54+
}
4255
}

0 commit comments

Comments
 (0)