You are here

public function FilesystemLoader::__construct in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Template/Loader/FilesystemLoader.php \Drupal\Core\Template\Loader\FilesystemLoader::__construct()

Constructs a new FilesystemLoader object.

Parameters

string|array $paths: A path or an array of paths to check for templates.

\Drupal\Core\Extension\ModuleHandlerInterface $module_handler: The module handler service.

\Drupal\Core\Extension\ThemeHandlerInterface $theme_handler: The theme handler service.

File

core/lib/Drupal/Core/Template/Loader/FilesystemLoader.php, line 32
Contains \Drupal\Core\Template\Loader\FilesystemLoader.

Class

FilesystemLoader
Loads templates from the filesystem.

Namespace

Drupal\Core\Template\Loader

Code

public function __construct($paths = array(), ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler) {
  parent::__construct($paths);

  // Add namespaced paths for modules and themes.
  $namespaces = array();
  foreach ($module_handler
    ->getModuleList() as $name => $extension) {
    $namespaces[$name] = $extension
      ->getPath();
  }
  foreach ($theme_handler
    ->listInfo() as $name => $extension) {
    $namespaces[$name] = $extension
      ->getPath();
  }
  foreach ($namespaces as $name => $path) {
    $this
      ->addPath($path . '/templates', $name);
  }
}