A
A
Andrey Godin2013-09-14 12:16:45
symfony
Andrey Godin, 2013-09-14 12:16:45

Template themes

Has anyone tried to tie themization in the symphony? I would like to do this through the admin panel, and not with the help of configs.

I'm thinking of creating a class in the twig extension, and then act in the image and likeness of loading themes from the database, only scatter the themes in folders.

$loader = new ThemeTwigLoader($this->container, $theme );
$this->twig = new \Twig_Environment($loader);


But then I will have to initialize the twig in my environment in each action, and this is a bunch of extra code. Maybe there is a more global solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zloyusr, 2013-09-14
@zloyusr

Define a service for ThemeTwigLoader with the twig.loader tag in the bundle:

acme_demo.twig.theme_loader:
    class: Acme\DemoBundle\Twig\Loader\ThemeTwigLoader
    arguments: [@service_container, ...]
    tags:
        - { name: twig.loader }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question