function ComponentNodeVisitor::getComponent
Same name in this branch
- 11.x core/modules/sdc/src/Twig/ComponentNodeVisitor.php \Drupal\sdc\Twig\ComponentNodeVisitor::getComponent()
Same name in other branches
- 10 core/modules/sdc/src/Twig/ComponentNodeVisitor.php \Drupal\sdc\Twig\ComponentNodeVisitor::getComponent()
- 10 core/lib/Drupal/Core/Template/ComponentNodeVisitor.php \Drupal\Core\Template\ComponentNodeVisitor::getComponent()
Finds the SDC for the current module node.
Parameters
\Twig\Node\Node $node: The node.
Return value
\Drupal\Core\Plugin\Component|null The component, if any.
1 call to ComponentNodeVisitor::getComponent()
- ComponentNodeVisitor::leaveNode in core/
lib/ Drupal/ Core/ Template/ ComponentNodeVisitor.php
File
-
core/
lib/ Drupal/ Core/ Template/ ComponentNodeVisitor.php, line 108
Class
- ComponentNodeVisitor
- Provides a ComponentNodeVisitor to change the generated parse-tree.
Namespace
Drupal\Core\TemplateCode
protected function getComponent(Node $node) : ?Component {
$component_id = $node->getTemplateName();
if (!preg_match('/^[a-z]([a-zA-Z0-9_-]*[a-zA-Z0-9])*:[a-z]([a-zA-Z0-9_-]*[a-zA-Z0-9])*$/', $component_id)) {
return NULL;
}
try {
return $this->pluginManager
->find($component_id);
} catch (ComponentNotFoundException) {
return NULL;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.