function drush_core_twig_compile

8.0.x core.drush.inc drush_core_twig_compile()
master core.drush.inc drush_core_twig_compile()

File

commands/core/core.drush.inc, line 1337
Core drush commands.

Code

function drush_core_twig_compile() {
  require_once DRUSH_DRUPAL_CORE . "/themes/engines/twig/twig.engine";
  // Scan all enabled modules and themes.
  // @todo Refactor to not reuse commandfile paths directly.
  $boot = drush_get_bootstrap_object();
  $searchpaths = $boot->commandfile_searchpaths(DRUSH_BOOTSTRAP_DRUPAL_FULL);
  $searchpaths[] = drupal_get_path('theme', drush_theme_get_default());
  $searchpaths[] = drupal_get_path('theme', drush_theme_get_admin());
  foreach ($searchpaths as $searchpath) {
    foreach ($file = drush_scan_directory($searchpath, '/\.html.twig/', array('tests')) as $file) {
      $relative = str_replace(drush_get_context('DRUSH_DRUPAL_ROOT') . '/', '', $file->filename);
      // @todo Dynamically disable twig debugging since there is no good info there anyway.
      twig_render_template($relative, array('theme_hook_original' => ''));
      drush_log(dt('Compiled twig template !path', array('!path' => $relative)), LogLevel::NOTICE);
    }
  }
}