Commit a8cc0ae4 authored by Fabien Potencier's avatar Fabien Potencier

feature #1310 Allow use of all the RequestMatcher parameters by providing an array (quazardous)

This PR was squashed before being merged into the 2.0.x-dev branch (closes #1310).

Discussion
----------

Allow use of all the RequestMatcher parameters by providing an array

Provider: Silex\Provider\SecurityServiceProvider
Little patch to make full use of the `RequestMatcher` in `$app['security.access_rules']`

```php
    $app['security.access_rules'] = [
        [[
            'host' => 'symfony.com',
            'ips' => '192.168.0.1',
            ...
         ], 'ROLE_ADMIN'],
        ...
    ];
```

Commits
-------

9698b776 Allow use of all the RequestMatcher parameters by providing an array
parents 83ce5871 9698b776
...@@ -334,8 +334,17 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener ...@@ -334,8 +334,17 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener
foreach ($app['security.access_rules'] as $rule) { foreach ($app['security.access_rules'] as $rule) {
if (is_string($rule[0])) { if (is_string($rule[0])) {
$rule[0] = new RequestMatcher($rule[0]); $rule[0] = new RequestMatcher($rule[0]);
} elseif (is_array($rule[0])) {
$rule[0] += [
'path' => null,
'host' => null,
'methods' => null,
'ips' => null,
'attributes' => null,
'schemes' => null,
];
$rule[0] = new RequestMatcher($rule[0]['path'], $rule[0]['host'], $rule[0]['methods'], $rule[0]['ips'], $rule[0]['attributes'], $rule[0]['schemes']);
} }
$map->add($rule[0], (array) $rule[1], isset($rule[2]) ? $rule[2] : null); $map->add($rule[0], (array) $rule[1], isset($rule[2]) ? $rule[2] : null);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment