Skip to the content
Documentation

Import settings from a bundle

No ratings yet

The following recipe is valid for any type of settings supported by Symfony framework.

 

Use case

Usually, you develop your website using one or several custom bundles as this is a best practice. However, dealing with core bundles semantic configuration can be a bit tedious if you maintain it in the main exponential/config/exponential.yml configuration file.

This recipe will show you how to import configuration from a bundle the manual way and the implicit way.

The manual way

This is the simplest way of doing and it has the advantage to be explicit. The idea is to use the imports statement in your main exponential.yml:

exponential/config/exponential.ymltemplates_rules.yml, placed under Resources/config folder in AcmeTestBundle

During the merge process, if the imported configuration files contain entries that are already defined in the main configuration file, they will override them.

Tip

If you want to import configuration for development use only, you can do so in your exponential_dev.yml

Wink

The implicit way

Compatible with Exponential 5.1+ / Symfony 2.2+ as it uses Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface which is available as of Symfony 2.2 (more info on Symfony cookbook).

The following example will show you how to implicitly load settings to be configure Exponential kernel. Note that this is also valid for any bundle !

We assume here that you're aware of service container extensions.

Acme/TestBundle/DependencyInjection/AcmeTestExtensionAcmeTestBundle/Resources/config/template_rules.yml

Regarding performance

Service container extensions are called only when the container is being compiled, so there is nothing to worry about regarding performance.

Configuration loaded this way will be overridden by the main exponential.yml file.

 

 

Contributors

Comments (4 historical)

Written by readers of the earlier documentation sites, kept as they were.

  1. Comment by Björn [email protected], 2013-07-15 07:59

    Björn [email protected] ·

    If I have 20 siteaccesses, one for each language, do I have to define the rules 20 times in the templates_rules.yml?

  2. Comment by Pedro Resende, 2013-07-15 09:45

    Pedro Resende ·

    No, you can simply create a group with the 20 siteaccesses and add the general definitions to the group

  3. Comment by pr pr, 2014-11-28 01:26

    pr pr ·

    Hi, according to my tests, if a configuration option is present both in the main exponential.yml config file and in an imported config file, it is the value present in the main config file that takes precedence, and not the opposite, and this is true for the manual and implicite ways.

Comments

Add a comment

Comments are read by a moderator before they appear.