function TwigComponentLoader::getSourceContext
Same name in other branches
- 11.x core/modules/sdc/src/Twig/TwigComponentLoader.php \Drupal\sdc\Twig\TwigComponentLoader::getSourceContext()
File
-
core/
modules/ sdc/ src/ Twig/ TwigComponentLoader.php, line 87
Class
- TwigComponentLoader
- Lets you load templates using the component ID.
Namespace
Drupal\sdc\TwigCode
public function getSourceContext($name) : Source {
try {
$component = $this->pluginManager
->find($name);
$path = $component->getTemplatePath();
} catch (ComponentNotFoundException $e) {
return new Source('', $name, '');
}
$original_code = file_get_contents($path);
return new Source($original_code, $name, $path);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.