[Security] Lazy load request matchers
This commit is contained in:
parent
2183f98f54
commit
5b72cf6950
|
@ -58,6 +58,8 @@ SecurityBundle
|
|||
* The `FirewallContext::getContext()` method has been deprecated and will be removed in 4.0.
|
||||
Use the `getListeners()` method instead.
|
||||
|
||||
* The `FirewallMap::$map` and `$container` properties have been deprecated and will be removed in 4.0.
|
||||
|
||||
TwigBridge
|
||||
----------
|
||||
|
||||
|
|
|
@ -164,6 +164,8 @@ SecurityBundle
|
|||
|
||||
* The `FirewallContext::getContext()` method has been removed, use the `getListeners()` method instead.
|
||||
|
||||
* The `FirewallMap::$map` and `$container` properties have been removed.
|
||||
|
||||
HttpFoundation
|
||||
---------------
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
3.3.0
|
||||
-----
|
||||
|
||||
* Deprecated the `FirewallMap::$map` and `$container` properties.
|
||||
|
||||
3.2.0
|
||||
-----
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityF
|
|||
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\DependencyInjection\Alias;
|
||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||
use Symfony\Component\DependencyInjection\ChildDefinition;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
|
@ -255,7 +256,7 @@ class SecurityExtension extends Extension
|
|||
|
||||
$map[$contextId] = $matcher;
|
||||
}
|
||||
$mapDef->replaceArgument(1, $map);
|
||||
$mapDef->replaceArgument(1, new IteratorArgument($map));
|
||||
|
||||
// add authentication providers to authentication manager
|
||||
$authenticationProviders = array_map(function ($id) {
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
|
||||
<service id="security.firewall.map" class="Symfony\Bundle\SecurityBundle\Security\FirewallMap" public="false">
|
||||
<argument type="service" id="service_container" />
|
||||
<argument type="collection" />
|
||||
<argument />
|
||||
</service>
|
||||
|
||||
<service id="security.firewall.context" class="Symfony\Bundle\SecurityBundle\Security\FirewallContext" abstract="true">
|
||||
|
|
|
@ -22,13 +22,94 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class FirewallMap implements FirewallMapInterface
|
||||
class FirewallMap extends _FirewallMap implements FirewallMapInterface
|
||||
{
|
||||
protected $container;
|
||||
protected $map;
|
||||
/**
|
||||
* @deprecated since version 3.3, to be removed in 4.0 alongside with magic methods below
|
||||
*/
|
||||
private $container;
|
||||
|
||||
/**
|
||||
* @deprecated since version 3.3, to be removed in 4.0 alongside with magic methods below
|
||||
*/
|
||||
private $map;
|
||||
|
||||
public function __construct(ContainerInterface $container, $map)
|
||||
{
|
||||
parent::__construct($container, $map);
|
||||
$this->container = $container;
|
||||
$this->map = $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if ('map' === $name || 'container' === $name) {
|
||||
@trigger_error(sprintf('Using the "%s::$%s" property is deprecated since version 3.3 as it will be removed/private in 4.0.', __CLASS__, $name), E_USER_DEPRECATED);
|
||||
|
||||
if ('map' === $name && $this->map instanceof \Traversable) {
|
||||
$this->map = iterator_to_array($this->map);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
if ('map' === $name || 'container' === $name) {
|
||||
@trigger_error(sprintf('Using the "%s::$%s" property is deprecated since version 3.3 as it will be removed/private in 4.0.', __CLASS__, $name), E_USER_DEPRECATED);
|
||||
|
||||
$set = \Closure::bind(function ($name, $value) { $this->$name = $value; }, $this, parent::class);
|
||||
$set($name, $value);
|
||||
}
|
||||
|
||||
$this->$name = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function __isset($name)
|
||||
{
|
||||
if ('map' === $name || 'container' === $name) {
|
||||
@trigger_error(sprintf('Using the "%s::$%s" property is deprecated since version 3.3 as it will be removed/private in 4.0.', __CLASS__, $name), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
return isset($this->$name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function __unset($name)
|
||||
{
|
||||
if ('map' === $name || 'container' === $name) {
|
||||
@trigger_error(sprintf('Using the "%s::$%s" property is deprecated since version 3.3 as it will be removed/private in 4.0.', __CLASS__, $name), E_USER_DEPRECATED);
|
||||
|
||||
$unset = \Closure::bind(function ($name) { unset($this->$name); }, $this, parent::class);
|
||||
$unset($name);
|
||||
}
|
||||
|
||||
unset($this->$name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal to be removed in 4.0
|
||||
*/
|
||||
class _FirewallMap
|
||||
{
|
||||
private $container;
|
||||
private $map;
|
||||
private $contexts;
|
||||
|
||||
public function __construct(ContainerInterface $container, array $map)
|
||||
public function __construct(ContainerInterface $container, $map)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->map = $map;
|
||||
|
|
|
@ -68,7 +68,7 @@ abstract class CompleteConfigurationTest extends \PHPUnit_Framework_TestCase
|
|||
$arguments = $container->getDefinition('security.firewall.map')->getArguments();
|
||||
$listeners = array();
|
||||
$configs = array();
|
||||
foreach (array_keys($arguments[1]) as $contextId) {
|
||||
foreach (array_keys($arguments[1]->getValues()) as $contextId) {
|
||||
$contextDef = $container->getDefinition($contextId);
|
||||
$arguments = $contextDef->getArguments();
|
||||
$listeners[] = array_map(function ($ref) { return (string) $ref; }, $arguments['index_0']);
|
||||
|
@ -180,7 +180,7 @@ abstract class CompleteConfigurationTest extends \PHPUnit_Framework_TestCase
|
|||
$arguments = $container->getDefinition('security.firewall.map')->getArguments();
|
||||
$matchers = array();
|
||||
|
||||
foreach ($arguments[1] as $reference) {
|
||||
foreach ($arguments[1]->getValues() as $reference) {
|
||||
if ($reference instanceof Reference) {
|
||||
$definition = $container->getDefinition((string) $reference);
|
||||
$matchers[] = $definition->getArguments();
|
||||
|
|
Reference in New Issue