function ComponentPluginManager::find

Same name in this branch
  1. 11.x core/lib/Drupal/Core/Theme/ComponentPluginManager.php \Drupal\Core\Theme\ComponentPluginManager::find()
Same name and namespace in other branches
  1. 10 core/modules/sdc/src/ComponentPluginManager.php \Drupal\sdc\ComponentPluginManager::find()

Gets a component for rendering.

@internal

Parameters

string $component_id: The component ID.

Return value

\Drupal\sdc\Plugin\Component The component.

Throws

\Drupal\sdc\Exception\ComponentNotFoundException

File

core/modules/sdc/src/ComponentPluginManager.php, line 138

Class

ComponentPluginManager
Defines a plugin manager to deal with sdc.

Namespace

Drupal\sdc

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);
}

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