You are here

public function SectionComponent::getPlugin in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/SectionComponent.php \Drupal\layout_builder\SectionComponent::getPlugin()

Gets the plugin for this component.

Parameters

\Drupal\Core\Plugin\Context\ContextInterface[] $contexts: An array of contexts to set on the plugin.

Return value

\Drupal\Component\Plugin\PluginInspectionInterface The plugin.

File

core/modules/layout_builder/src/SectionComponent.php, line 242

Class

SectionComponent
Provides a value object for a section component.

Namespace

Drupal\layout_builder

Code

public function getPlugin(array $contexts = []) {
  $plugin = $this
    ->pluginManager()
    ->createInstance($this
    ->getPluginId(), $this
    ->getConfiguration());
  if ($contexts && $plugin instanceof ContextAwarePluginInterface) {
    $this
      ->contextHandler()
      ->applyContextMapping($plugin, $contexts);
  }
  return $plugin;
}