You can make %check_path% (or the version with named names) a "normal" parameter: Inside DependencyInjection there are (by default) two classes responsible for defining and loading the package configuration. There you can also enter your configuration into your service container.
DependencyInjection\Configuration is where you determine which configurations are available in your bundle, what type they should be, etc.
DependencyInjection\YourBundleNameExtension is the place where you can load your configuration and add it to the service container.
If you haven't done anything yet, your load() extension method should look something like this:
public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); $loader = new Loader\YamlFileLoader( $container, new FileLocator(__DIR__.'/../Resources/config') ); $loader->load('services.yml'); }
$config stores the configuration of your package as an array, so if you imagine that your YAML configuration file looks like this:
your_bundle_name: check_path: foo
Your $config will look like this:
array( 'check_path' => 'foo' )
So now you need to add this configuration to the container. Inside your load() method, just add something like:
$container->setParameter( 'my_bundle_name.check_path', $config['check_path'] );
Inside services.yml you can now use %my_bundle_name.check_path% , like any other parameter:
my_bundle_name.security.authentication.provider: class: MyBundleName\Security\Core\Authentication\Provider\MyAuthenticationProvider arguments: ['%my_bundle_name.check_path%']
See the Symfony documentation [ 1 , 2 ] for more information.
source share