I'm trying to get the access_control parameters wich are located in my security.yml as an array in my custom service.
Just like with getting the role_hierarchy parametes I thought it would work with the following code:
$accessParameters = $this->container->getParameter('security.access_control');
Unfortunately this was not the case.
Can someone tell how to get the parameters?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
There's no way to get the
access_control
parameter from the container.This is because this parameter is only used to create request matchers which will be registered as AccessMap later given in the AccessListener, and then are left over without registering it into the container.
You can try something hacky to get these matchers back by getting them like
But this is kind of an ugly solution.
Another way I can see on how to get them is to parse again the security file
If you want to register this configuration into a service, you can do something like
services.yml
Acme\FooBundle\ConfigProvider
Acme\FooBundle\MyService