You are here

public function PluginCollectionItemBase::validatePluginInstance in Plugin 8.2

Validates a plugin instance.

Parameters

\Drupal\Component\Plugin\PluginInspectionInterface $plugin_instance:

Throws

\Exception

Overrides PluginCollectionItemInterface::validatePluginInstance

Deprecated

Deprecated as of 8.x-2.0 and scheduled for removal before 8.x-3.0. Use static::getPluginType()->getPluginManager()->hasDefinition() instead.

1 call to PluginCollectionItemBase::validatePluginInstance()
PluginCollectionItemBase::createContainedPluginInstance in src/Plugin/Field/FieldType/PluginCollectionItemBase.php
Creates a plugin instance.

File

src/Plugin/Field/FieldType/PluginCollectionItemBase.php, line 37

Class

PluginCollectionItemBase
Provides a base for plugin collection field items.

Namespace

Drupal\plugin\Plugin\Field\FieldType

Code

public function validatePluginInstance(PluginInspectionInterface $plugin_instance) {
  $plugin_manager = $this
    ->getPluginType()
    ->getPluginManager();
  if (!$plugin_manager
    ->hasDefinition($plugin_instance
    ->getPluginId())) {
    throw new PluginNotFoundException($plugin_instance
      ->getPluginId(), sprintf('Plugin manager %s does not have a definition for plugin %s.', get_class($plugin_manager), $plugin_instance
      ->getPluginId()));
  }
}