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 1345
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 since \Drush\Boot\DrupalBoot::commandfile_searchpaths is similar.
  $ignored_modules = drush_get_option_list('ignored-modules', array());
  $cid = drush_cid_install_profile();
  if ($cached = drush_cache_get($cid)) {
    $ignored_modules[] = $cached->data;
  }
  foreach (array_diff(drush_module_list(), $ignored_modules) as $module) {
    $searchpaths[] = drupal_get_path('module', $module);
  }

  $themes = drush_theme_list();
  foreach ($themes as $name => $theme) {
    $searchpaths[] = $theme->getPath();
  }

  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::INFO);
    }
  }
}