user3631654
user3631654

Reputation: 1785

Symfony: How to handle config in Bundle

I'm having trouble finding the correct tutorial for me. I'm trying to have a controller-configuration in my bundle in Resources/config/someconfig.yml. I already adjusted it to a .yml extension. Now I'm searching a solution to access this configuration inside a twig exception controller (404-pages) and merge this configuration with the config.yml in app/config/.

Can anybody help me with a tutorial link or tips?

Thank you!

Upvotes: 1

Views: 210

Answers (2)

martin
martin

Reputation: 96899

For merging configurations among independent bundles you should use prependExtensionConfig method and PrependExtensionInterface interface.

Documentaion page How to Simplify Configuration of multiple Bundles explains this technique in great detail.

Upvotes: 0

Sergei Gorjunov
Sergei Gorjunov

Reputation: 1799

To get Resources/config/someconfig.yml config you can create DI extension: http://symfony.com/doc/current/cookbook/bundles/extension.html

I think this can help you to get configuration value in view: How to get config parameters in Symfony2 Twig Templates

As an alternative you can override Exception controller (get configuration parameters there and pass them to the view): http://symfony.com/doc/current/cookbook/controller/error_pages.html#replace-the-default-exception-controller

Upvotes: 1

Related Questions