Skip to content
This repository has been archived by the owner on Jul 4, 2018. It is now read-only.

Commit

Permalink
feature #1310 Allow use of all the RequestMatcher parameters by provi…
Browse files Browse the repository at this point in the history
…ding 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
-------

9698b77 Allow use of all the RequestMatcher parameters by providing an array
  • Loading branch information
fabpot committed Mar 10, 2016
2 parents 83ce587 + 9698b77 commit a8cc0ae
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Silex/Provider/SecurityServiceProvider.php
Expand Up @@ -334,8 +334,17 @@ public function register(Container $app)
foreach ($app['security.access_rules'] as $rule) {
if (is_string($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);
}

Expand Down

0 comments on commit a8cc0ae

Please sign in to comment.