Dynamic configuration¶
ConfigResolver¶
Dynamic configuration is handled by the ConfigResolverInterface.
It exposes the hasParameter() and getParameter() methods.
You can use them to check the different scopes available for a given namespace to find the appropriate parameter.
To work with the ConfigResolver, your dynamic settings must have the following name format: <namespace>.<scope>.parameter.name.
1 2 3 4 5 6 7 8 9 10 11 | |
Inside a controller extending the Ibexa\Core\MVC\Symfony\Controller\Controller class, in site_group SiteAccess, you can use the parameters in the following way (the same applies for hasParameter()):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Tip
To learn more about scopes, see SiteAccess documentation.
Both getParameter() and hasParameter() can take three arguments:
$paramName- the name of the parameter$namespace- your application namespace,myappin the previous example. If null, the default namespace is used, which isibexa.site_access.configby default.$scope- a SiteAccess name. If null, the current SiteAccess is used.
Inject ConfigResolver into services¶
You can use the ConfigResolver in your own services whenever needed.
To do this, inject the ibexa.config.resolver service:
1 2 3 | |
You can also use the autowire feature, by type hinting against ConfigResolverInterface.
For more information about dependency injection, see Service container.
Note
Don't store the retrieved config value unless you know what you're doing. SiteAccess can change during code execution, which means you might work on the wrong value.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |