8000 Avoid deprecation of FirewallContext::getContext() · symfony/symfony@6ea2a15 · GitHub
[go: up one dir, main page]

Skip to content
< 8000 header class="HeaderMktg header-logged-out js-details-container js-header Details f4 py-3" role="banner" data-is-top="true" data-color-mode=light data-light-theme=light data-dark-theme=dark>

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6ea2a15

Browse files
committed
Avoid deprecation of FirewallContext::getContext()
1 parent 00e870a commit 6ea2a15

File tree

4 files changed

+23
-41
lines changed

4 files changed

+23
-41
lines changed

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,13 @@ public function __construct(array $listeners, ExceptionListener $exceptionListen
3232
$this->config = $config;
3333
}
3434

35-
public function getListeners()
36-
{
37-
return array($this->listeners, $this->exceptionListener);
38-
}
39-
4035
public function getConfig()
4136
{
4237
return $this->config;
4338
}
4439

45-
/**
46-
* @deprecated since 3.2. Use {@see getListeners()} instead.
47-
*
48-
* @return array
49-
*/
5040
public function getContext()
5141
{
52-
@trigger_error(sprintf('Method %s() is deprecated since version 3.2 and will be removed in 4.0. Use %s::getListeners() instead.', __METHOD__, __CLASS__), E_USER_DEPRECATED);
53-
5442
return array($this->listeners, $this->exceptionListener);
5543
}
5644
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ public function getListeners(Request $request)
4141
return array(array(), null);
4242
}
4343

44-
return $context->getListeners();
44+
return $context->getContext();
4545
}
4646

4747
/**
4848
* Gets the firewall for a given Request.
4949
*
5050
* @param Request $request
5151
*
52-
* @return Firewall|null The matching firewall
52+
* @return FirewallContext|null The matching context
5353
*/
5454
public function getContext(Request $request)
5555
{

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ public function testGetters()
4848
$this->assertSame($options['user_checker'], $config->getUserChecker());
4949

5050
// Listener configs
51-
$expectedConfigs = array('logout' => $options['logout'], 'remember_me' => $options['remember_me'], 'anonymous' => $options['anonymous']);
51+
$expectedConfigs = array(
52+
'logout' => $options['logout'],
53+
'remember_me' => $options['remember_me'],
54+
'anonymous' => $options['anonymous'],
55+
);
56+
5257
$this->assertSame($expectedConfigs, $config->getListenerConfigs());
5358
}
5459
}

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

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,26 @@ class FirewallContextTest extends \PHPUnit_Framework_TestCase
2020
{
2121
public function testGetConfig()
2222
{
23-
$config = $this->getFirewallConfigMock();
24-
$exceptionListener = $this->getExceptionListenerMock();
25-
$listeners = array($this->getListenerMock());
26-
27-
$context = new FirewallContext($listeners, $exceptionListener, $config);
28-
29-
$this->assertEquals(array($listeners, $exceptionListener), $context->getListeners());
30-
$this->assertEquals($config, $context->getConfig());
31-
}
32-
33-
private function getExceptionListenerMock()
34-
{
35-
return $this
36-
->getMockBuilder(ExceptionListener::class)
23+
$config = $this
24+
->getMockBuilder(FirewallConfig::class)
3725
->disableOriginalConstructor()
3826
->getMock();
39-
}
4027

41-
private function getListenerMock()
42-
{
43-
return $this
44-
->getMockBuilder(ListenerInterface::class)
28+
$exceptionListener = $this
29+
->getMockBuilder(ExceptionListener::class)
4530
->disableOriginalConstructor()
4631
->getMock();
47-
}
4832

49-
private function getFirewallConfigMock()
50-
{
51-
return $this
52-
->getMockBuilder(FirewallConfig::class)
53-
->disableOriginalConstructor()
54-
->getMock();
33+
$listeners = array(
34+
$this
35+
->getMockBuilder(ListenerInterface::class)
36+
->disableOriginalConstructor()
37+
->getMock(),
38+
);
39+
40+
$context = new FirewallContext($listeners, $exceptionListener, $config);
41+
42+
$this->assertEquals(array($listeners, $exceptionListener), $context->getContext());
43+
$this->assertEquals($config, $context->getConfig());
5544
}
5645
}

0 commit comments

Comments
 (0)
0