Didier Ghys
Didier Ghys

Reputation: 30666

Override service definitions parameters by configuration

I have noticed in several bundles that some services definition files had parameters embedded in it, like in the following example:

<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

    <parameters>
        <!-- CUSTOMER -->
        <parameter key="sonata.customer.admin.customer.class">Sonata\CustomerBundle\Admin\CustomerAdmin</parameter>
        <parameter key="sonata.customer.admin.customer.controller">SonataAdminBundle:CRUD</parameter>
    </parameters>

    <services>
        <service id="sonata.customer.admin.customer" class="%sonata.customer.admin.customer.class%">
            <tag name="sonata.admin" manager_type="orm" group="sonata_ecommerce" label="B2C" label_translator_strategy="sonata.admin.label.strategy.underscore"/>
            <argument />
            <argument>%sonata.customer.admin.customer.entity%</argument>
            <argument>%sonata.customer.admin.customer.controller%</argument>

            <call method="addChild">
                <argument type="service" id="sonata.customer.admin.address" />
            </call>

            <call method="addChild">
                <argument type="service" id="sonata.order.admin.order" />
            </call>
        </service>

    </services>

</container>

Those parameters are not exposed as bundle configuration.

I recently discovered it is possible to add a CompilerPass class to override some service definitions. Although, this looks a bit tedious to do.

Is it possible to override those <parameter> by configuration ?

Upvotes: 3

Views: 2054

Answers (1)

Yann Eugon&#233;
Yann Eugon&#233;

Reputation: 1361

In your app/config/config.yml (or whatever imported config file) add :

parameters:
    parameter.name: new_value

Upvotes: 6

Related Questions