/**
  * {@inheritdoc}
  */
 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()));
     }
 }
 /**
  * Constructs a PluginWrapper object.
  *
  * @param PluginInspectionInterface $plugin
  *   The plugin to wrap.
  */
 public function __construct(PluginInspectionInterface $plugin)
 {
     $this->plugin = $plugin;
     $this->pluginDefinition = $plugin->getPluginDefinition();
     // For configurable plugins, expose those properties as well.
     if ($plugin instanceof ConfigurablePluginInterface) {
         $this->pluginConfiguration = $plugin->getConfiguration();
     }
 }
 /**
  * Calculates and adds dependencies of a specific plugin instance.
  *
  * Dependencies are added for the module that provides the plugin, as well
  * as any dependencies declared by the instance's calculateDependencies()
  * method, if it implements
  * \Drupal\Component\Plugin\ConfigurablePluginInterface.
  *
  * @param \Drupal\Component\Plugin\PluginInspectionInterface $instance
  *   The plugin instance.
  */
 protected function calculatePluginDependencies(PluginInspectionInterface $instance)
 {
     $definition = $instance->getPluginDefinition();
     $this->addDependency('module', $definition['provider']);
     // Plugins can declare additional dependencies in their definition.
     if (isset($definition['config_dependencies'])) {
         $this->addDependencies($definition['config_dependencies']);
     }
     // If a plugin is configurable, calculate its dependencies.
     if ($instance instanceof ConfigurablePluginInterface && ($plugin_dependencies = $instance->calculateDependencies())) {
         $this->addDependencies($plugin_dependencies);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function calculatePluginDependencies(PluginInspectionInterface $instance)
 {
     // Only add dependencies for plugins that are enabled.
     // @see \Drupal\userprotect\Plugin\UserProtection\UserProtectionPluginCollection::getConfiguration()
     if (isset($this->protections[$instance->getPluginId()])) {
         parent::calculatePluginDependencies($instance);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function setSelectedPlugin(PluginInspectionInterface $plugin)
 {
     $this->validateSelectablePluginType();
     $this->selectedPlugin = $plugin;
     if ($this->getKeepPreviouslySelectedPlugins()) {
         $this->previouslySelectedPlugins[$plugin->getPluginId()] = $plugin;
     }
     return $this;
 }
Exemple #6
0
 /**
  * {@inheritdoc}
  */
 protected function calculatePluginDependencies(PluginInspectionInterface $instance)
 {
     // Only add dependencies for plugins that are actually configured. This is
     // necessary because the filter plugin collection will return all available
     // filter plugins.
     // @see \Drupal\filter\FilterPluginCollection::getConfiguration()
     if (isset($this->filters[$instance->getPluginId()])) {
         parent::calculatePluginDependencies($instance);
     }
 }