function TwigComponentLoader::exists

Same name in other branches
  1. 10 core/modules/sdc/src/Twig/TwigComponentLoader.php \Drupal\sdc\Twig\TwigComponentLoader::exists()

File

core/modules/sdc/src/Twig/TwigComponentLoader.php, line 70

Class

TwigComponentLoader
Lets you load templates using the component ID.

Namespace

Drupal\sdc\Twig

Code

public function exists($name) : bool {
    if (!preg_match('/^[a-zA-Z][a-zA-Z0-9:_-]*[a-zA-Z0-9]?$/', $name)) {
        return FALSE;
    }
    try {
        $this->pluginManager
            ->find($name);
        return TRUE;
    } catch (ComponentNotFoundException $e) {
        Error::logException($this->logger, $e);
        return FALSE;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.