Override service definition parameters by configuration

In several packages, I've noticed that some service definition files have parameters built into it, as 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>

      

These parameters are not displayed as a beam configuration.

I recently discovered that it is possible to add a class CompilerPass

to override some of the service definitions. It looks a little tedious, though.

Can these be overridden <parameter>

by configuration?

+3


source to share


1 answer


In your app/config/config.yml

(or any other imported config file) add:



parameters:
    parameter.name: new_value

      

+6


source







All Articles