function ComponentLoader::getSourceContext
File
- 
              core/lib/ Drupal/ Core/ Template/ Loader/ ComponentLoader.php, line 85 
Class
- ComponentLoader
- Lets you load templates using the component ID.
Namespace
Drupal\Core\Template\LoaderCode
public function getSourceContext($name) : Source {
  try {
    $component = $this->pluginManager
      ->find($name);
    $path = $component->getTemplatePath();
  } catch (ComponentNotFoundException) {
    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.
