function ComponentLoader::exists

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Template/Loader/ComponentLoader.php \Drupal\Core\Template\Loader\ComponentLoader::exists()

File

core/lib/Drupal/Core/Template/Loader/ComponentLoader.php, line 68

Class

ComponentLoader
Lets you load templates using the component ID.

Namespace

Drupal\Core\Template\Loader

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.