Ibexa DXP Discussions

Community discussion forum for developers working with Ibexa DXP

Importing settings from a bundle


I’ve just started creating my first bundle, for my first eZPlatform website.
I would like to avoid, as much as possible, to write/modify *.yml files into the “./app/config/” folder, thus I would like to create my own *.yml files specific to my bundle, into the “./src/mycompany/mybundleBundle/Resources/config/” folder, such as ezplatform.yml file, etc…

Then I’ve read the following doc:

If possible, I want to avoid the “manual way” (which means importing resources into the ./app/config/ezplatform.yml).

Better, I would like to use the “implicit way”:
1/ I’ve created my own "./src/mycompany/mybundleBundle/Resources/config/ezplatform.yml (WITHOUT the firt line “ezpublish:”):

                    template: "MyBundle:full:root_folder.html.twig"
                        Id\Location: 2

2/ I’ve written a prepend() function into ./src/mycompany/mybundleBundle/DependencyInjection/MyBundleExtention.php

public function prepend( ContainerBuilder $container )
    // Loading our YAML file containing our template rules
    $configFile = __DIR__ . '/../Resources/config/ezplatform.yml';
    $config = Yaml::parse( file_get_contents( $configFile ) );
    // We explicitly prepend loaded configuration for "ezpublish" namespace.
    // So it will be placed under the "ezpublish" configuration key, like in ezpublish.yml.
    $container->prependExtensionConfig( 'ezpublish', $config );
    $container->addResource( new FileResource( $configFile ) );

3/ I’ve my placed my twig template into the right folder: /src/mycompany/mybundleBundle/Resources/views/full/root_folder.html.twig

… it doesn’t work.
“root_folder.html.twig” templates is not called when I try to access http://mysite/
I’m getting crazy, I don’t know what’s wrong.

Any idea ?

I’ve found what was wrong !
It was my mistake.
Instead of removing this post, I give the answer… if it can help newbies like me…

The class “MyBundleExtension” must extend “Extension” AND implement “PrependExtensionInterface” (which I had forgotten).

class MyBundleExtension extends Extension implements PrependExtensionInterface

Hello @storton

I’m pleased you were able to resolve your omission / error.

BC made an example extension long ago to prove that this most basic functionality can be leveraged:

While this does not specifically cover all possible kinds of settings overrides and is a little outdated for ezplatform’s latest version it does do it’s job.

We hope this helps others!


1 Like

Cool that you solved your problem and thanks for sharing the answer.
I mark this topic as resolved.