Skip to content

Instantly share code, notes, and snippets.

@mpiecko
Created July 15, 2012 10:31
Show Gist options
  • Save mpiecko/3116204 to your computer and use it in GitHub Desktop.
Save mpiecko/3116204 to your computer and use it in GitHub Desktop.
Using boot() to add global variables in Twig
<?php
namespace My\BackendBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class BackendBundle extends Bundle
{
public function boot()
{
$twig = $this->container->get('twig');
$twig->addGlobal('backend', array(
'title' => $this->container->getParameter('backend.title')
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment