raindrop / twigloader-bundle
Symfony Raindrop TwigLoaderBundle
Installs: 108
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.3
- doctrine/doctrine-bundle: 1.1.*
- doctrine/orm: >=2.2.3,<2.4-dev
- sonata-project/doctrine-extensions: 1.*
- symfony/framework-bundle: >=2.1.0,<2.3
- symfony/monolog-bundle: >=2.1,<3
- twig/twig: >=1.6.0,<2.0
Requires (Dev)
- symfony/class-loader: 2.1.x@dev
- symfony/finder: 2.1.x@dev
- symfony/form: 2.1.x@dev
- symfony/twig-bridge: 2.1.x@dev
- symfony/twig-bundle: 2.1.x@dev
- symfony/yaml: 2.1.x@dev
This package is not auto-updated.
Last update: 2024-11-09 15:42:27 UTC
README
This bundle adds database support for twig templates. It substitutes Twig_Loader_FileSystem with Twig_Loader_Chain and appends Database and FileSystem loader. To load from database, use database: syntax into render method.
INSTALLATION:
First add the dependency to your composer.json` file:
"require": {
...
"raindrop/twigloader-bundle": "dev-master"
},
Then install the bundle with the command:
php composer.phar update
Enable the bundle in your application kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Raindrop\TwigLoaderBundle\RaindropTwigLoaderBundle(), ); }
Now the bundle is enabled.
There is also a TwigTemplateAdmin
class activated only if SonataAdmin
bundle is enabled in your AppKernel.php.
CONFIGURATION:
This the default configuration and can be overridden in app/config/config.yml
:
doctrine: dbal: types: json: Sonata\Doctrine\Types\JsonType
and
raindrop_twig_loader: chain: replace_twig_loader: true loaders_by_id: raindrop_twig.loader.filesystem: 10 raindrop_twig.loader.database: 20
This configures twig chain loader and append those specified above.
USAGE:
Load template from database:
class myController { public function indexAction() { return $this->render('database:contact_us_en'); } }
The database loader will load the template using ::getTemplate() method and pass result to controller render method.