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

Breadcrumb

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

function ComponentPluginManager::find

Gets a component for rendering.

Parameters

string $component_id: The component ID.

Return value

\Drupal\Core\Plugin\Component The component.

Throws

\Drupal\Core\Render\Component\Exception\ComponentNotFoundException

File

core/lib/Drupal/Core/Theme/ComponentPluginManager.php, line 133

Class

ComponentPluginManager
Defines a plugin manager to deal with components.

Namespace

Drupal\Core\Theme

Code

public function find(string $component_id) : Component {
    $definitions = $this->getDefinitions();
    if (empty($definitions)) {
        throw new ComponentNotFoundException('Unable to find any component definition.');
    }
    $negotiated_plugin_id = $this->componentNegotiator
        ->negotiate($component_id, $definitions);
    return $this->createInstance($negotiated_plugin_id ?? $component_id);
}

API Navigation

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