Download the PHP package scaytrase/symfony-switchable-theme without Composer
On this page you can find all versions of the php package scaytrase/symfony-switchable-theme. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download scaytrase/symfony-switchable-theme
More information about scaytrase/symfony-switchable-theme
Files in scaytrase/symfony-switchable-theme
Package symfony-switchable-theme
Short Description Web-configurable forms
License GPL-2.0+
Informations about the package symfony-switchable-theme
scaytrase/symfony-switchable-theme
Runtime choosing for Twig {% extends %}
clause
[]()
[
]()
[
]()
[]()
[
]()
Run-time switchable and user-configurable twig layouts
Originally developed to use with BraincraftedBootstrapBundle theme switcher allows you to dynamically define twig extended templates at runtime. Also you can compile assets for your theme if you need. Current version supports theme configuration, so themes can be preconfigured (and have multiple configuration instances for single theme) as same as each configuration can be compiled separately.
Usage
Basic example
See tests for basic usage example. You can find simple ThemeInterface
implementation and logic example.
Commons
To use theme switch you should simply extend a template name, returned by method. This method returns a string representing really extended template (i.e. ) or null
Fallback layout
To use theme switch in case you are not shure, that template exists you can use multi-extends twig clause and supply it with fallback template, i.e.
The main idea is that 'my_theme' and 'base' strings could be replaced with variables populated from DB or user session. This allows you to dynamically select parent template for given conditions
Configurable themes
To use theme with theme configurations (theme instances) you should provide object for the first argument to getTemplate. Configurable themes should implement ConfigurableThemeInterface
to be able to be configured.
Compilable themes
Some themes should be processed before they can be used. For example, some theme assets should be compiled. To handle theese situations CompilableThemeInterface
was created. Theme can be compiled by calling CompilableThemeInterface::compile()
method. This way is best used with configurable interface, so you can compile different configurations of single theme.
As quick example there is an abstract base class for creating Bootstrap 3.0 based theme. You could implement the accessing methods which points the class to the bootstrap less template, vendor assets, etc and results in correctly compiled bootstrap.css
on CompilableThemeInterface::compile()
call.
Theme compilation method based on bootstrap compilation workflow from braincrafted/bootstrap-bundle
All versions of symfony-switchable-theme with dependencies
symfony/framework-bundle Version ~2.3
symfony/console Version ~2.3
symfony/form Version ~2.3
twig/twig Version ~1.17
twig/extensions Version ~1.2
doctrine/orm Version ~2.2,>=2.2.3
doctrine/doctrine-bundle Version ~1.2
sensio/framework-extra-bundle Version ~3.0
scaytrase/symfony-autoregistry Version ~2.0
symfony/assetic-bundle Version ~2.6