8000 [SecurityBundle] Enhance FirewallContext::getListeners() by ro0NL · Pull Request #22475 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[SecurityBundle] Enhance FirewallContext::getListeners() #22475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion UPGRADE-3.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion UPGRADE-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
13 changes: 9 additions & 4 deletions src/Symfony/Bundle/SecurityBundle/Security/FirewallContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,22 @@ public function getConfig()
}

/**
* @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;
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function getListeners(Request $request)
return array(array(), null);
}

return $context->getListeners();
return array($context->getListeners(), $context->getExceptionListener());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,21 @@ public function testGetters()

$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()
Expand Down
0