Registers Twig services.
This method is public and static so that it can be reused in the installer.
public static function registerTwig(ContainerBuilder $container) {
$container
->register('twig.loader.filesystem', 'Twig_Loader_Filesystem')
->addArgument(DRUPAL_ROOT);
$container
->setAlias('twig.loader', 'twig.loader.filesystem');
$container
->register('twig', 'Drupal\\Core\\Template\\TwigEnvironment')
->addArgument(new Reference('twig.loader'))
->addArgument(array(
// This is saved / loaded via drupal_php_storage().
// All files can be refreshed by clearing caches.
// @todo ensure garbage collection of expired files.
// When in the installer, twig_cache must be FALSE until we know the
// files folder is writable.
'cache' => drupal_installation_attempted() ? FALSE : settings()
->get('twig_cache', TRUE),
'base_template_class' => 'Drupal\\Core\\Template\\TwigTemplate',
// @todo Remove in followup issue
// @see http://drupal.org/node/1712444.
'autoescape' => FALSE,
// @todo Remove in followup issue
// @see http://drupal.org/node/1806538.
'strict_variables' => FALSE,
'debug' => settings()
->get('twig_debug', FALSE),
'auto_reload' => settings()
->get('twig_auto_reload', NULL),
))
->addMethodCall('addExtension', array(
new Definition('Drupal\\Core\\Template\\TwigExtension'),
))
->addMethodCall('addExtension', array(
new Definition('Twig_Extension_Debug'),
));
}