class ViewsTemplateLoader in Views Templates 8
Service class to load templates from the file system.
Hierarchy
- class \Drupal\views_templates\ViewsTemplateLoader implements ViewsTemplateLoaderInterface
Expanded class hierarchy of ViewsTemplateLoader
1 string reference to 'ViewsTemplateLoader'
1 service uses ViewsTemplateLoader
File
- src/
ViewsTemplateLoader.php, line 12
Namespace
Drupal\views_templatesView source
class ViewsTemplateLoader implements ViewsTemplateLoaderInterface {
/**
* {@inheritdoc}
*/
public function load(ViewsDuplicateBuilderPluginInterface $builder) {
$templates =& drupal_static(__FUNCTION__, []);
$template_id = $builder
->getViewTemplateId();
if (!isset($templates[$template_id])) {
$dir = drupal_get_path('module', $builder
->getDefinitionValue('provider')) . '/views_templates';
if (is_dir($dir)) {
$file_path = $dir . '/' . $builder
->getViewTemplateId() . '.yml';
if (is_file($file_path)) {
$templates[$template_id] = Yaml::decode(file_get_contents($file_path));
}
else {
throw new FileNotFoundException($file_path);
}
}
}
return $templates[$template_id];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ViewsTemplateLoader:: |
public | function |
Load template array values from file system for builder plugin. Overrides ViewsTemplateLoaderInterface:: |