Stepan Yudin
Stepan Yudin

Reputation: 480

Symfony how to extend default bundle config?

Lets imagine i have a bundle with service config loaded via DependencyInjection/VendorAcmeExtension.php

There are Configuration.php class that loads some parameter default value (array of values).

The question: how to extend default values? In theory i have to set param value via config.yml, but this will override default value. But i need to add my value to default value array instead of override this default array

Update

Sorry for my engish (

For example vendor bundle have Configuration.php that loads default values:

    $rootNode
        ->children()
                ...
                ->defaultValue(
                    array(
                        'entity'=>array(
                            'label' => 'oro.user.privileges.entity.label',
                            'view_type' => 'grid',
                            'types' => array('entity'),
                            'field_type' => 'oro_acl_access_level_selector',
                            'fix_values' => false,
                            'default_value' => 5,
                            'show_default' => true,
                        ),
                        'action'=>array(
                            'label' => 'oro.user.privileges.action.label',
                            'view_type' => 'list',
                            'types' => array('action'),
                            'field_type' => 'oro_acl_access_level_selector',
                            'fix_values' => false,
                            'default_value' => 1,
                            'show_default' => false,
                        )
                    )
                )
                ...

This default value contains an array I need to add new element to this array. If i do this in config.yml - i will overwrite default values. But all i want is to push new element

Upvotes: 1

Views: 2140

Answers (1)

giosh94mhz
giosh94mhz

Reputation: 3116

If you need to override parts of a bundle, you could you bundle inheritance, but this is pretty rare IMO.

To override the default configuration, you could just define a prepended configuration method; this works just like if you put a config block at the top of your config.yml file (sort of).

Upvotes: 1

Related Questions