Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ComponentLoader.php

function ComponentLoader::exists

Overrides LoaderInterface::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;
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal