public static function CoreBundle::registerTwig

Registers Twig services.

This method is public and static so that it can be reused in the installer.

2 calls to CoreBundle::registerTwig()
CoreBundle::build in drupal/core/lib/Drupal/Core/CoreBundle.php
Implements \Symfony\Component\HttpKernel\Bundle\BundleInterface::build().
install_begin_request in drupal/core/includes/install.core.inc
Begins an installation request, modifying the installation state as needed.

File

drupal/core/lib/Drupal/Core/CoreBundle.php, line 94
Definition of Drupal\Core\CoreBundle.

Class

CoreBundle
Bundle class for mandatory core services.

Namespace

Drupal\Core

Code

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'),
  ));
}