You are here

public function ResponseTemplateLoader::__construct in Apigee Edge 8

Constructs a new FilesystemLoader object.

Parameters

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

File

tests/modules/apigee_mock_api_client/src/TwigExtension/ResponseTemplateLoader.php, line 36

Class

ResponseTemplateLoader
Loads templates from the response-templates folder of a module.

Namespace

Drupal\apigee_mock_api_client\TwigExtension

Code

public function __construct(ModuleHandlerInterface $module_handler) {
  $modules = $module_handler
    ->getModuleList();
  $paths = array_map(function ($module) {
    return $module
      ->getPath() . '/tests/response-templates';
  }, $modules);

  // Filter out core paths & those without a response-templates directory.
  $paths = array_filter($paths, function ($path) {
    return strpos($path, 'core/') !== 0 && is_dir(DRUPAL_ROOT . "/{$path}");
  });
  parent::__construct($paths);
}