abstract class ExecutablePluginBase

Provides the basic architecture for executable plugins.

Hierarchy

Expanded class hierarchy of ExecutablePluginBase

1 file declares its use of ExecutablePluginBase

File

drupal/core/lib/Drupal/Core/Executable/ExecutablePluginBase.php, line 17
Contains \Drupal\Core\Executable\ExecutablePluginBase.

Namespace

Drupal\Core\Executable
View source
abstract class ExecutablePluginBase extends ContextAwarePluginBase implements ExecutableInterface {

  /**
   * The condition manager to proxy execute calls through.
   *
   * @var \Drupal\Component\Plugin\PluginManagerInterface
   */
  protected $executableManager;

  /**
   * {@inheritdoc}
   */
  public function setExecutableManager(ExecutableManagerInterface $executableManager) {
    $this->executableManager = $executableManager;
    return $this;
  }

  /**
   * Gets an array of definitions of available configuration options.
   *
   * @todo: This needs to go into an interface.
   *
   * @return array
   *   An array of typed data definitions describing available configuration
   *   options, keyed by option name.
   */
  public function getConfigDefinitions() {
    $definition = $this
      ->getPluginDefinition();
    if (!empty($definition['configuration'])) {
      return $definition['configuration'];
    }
    return array();
  }

  /**
   * Gets the definition of a configuration option.
   *
   * @todo: This needs to go into an interface.
   *
   * @return array
   *   The typed data definition describing the configuration option, or FALSE
   *   if the option does not exist.
   */
  public function getConfigDefinition($key) {
    $definition = $this
      ->getPluginDefinition();
    if (!empty($definition['configuration'][$key])) {
      return $definition['configuration'][$key];
    }
    return FALSE;
  }

  /**
   * Gets all configuration values.
   *
   * @todo: This needs to go into an interface.
   *
   * @return array
   *   The array of all configuration values, keyed by configuration option
   *   name.
   */
  public function getConfig() {
    return $this->configuration;
  }

  /**
   * Sets the value of a particular configuration option.
   *
   * @param string $name
   *   The name of the configuration option to set.
   * @param mixed $value
   *   The value to set.
   *
   * @todo This doesn't belong here. Move this into a new base class in
   *   http://drupal.org/node/1764380.
   * @todo This does not set a value in config(), so the name is confusing.
   *
   * @return \Drupal\Core\Executable\ExecutablePluginBase.
   *   The executable object for chaining.
   */
  public function setConfig($key, $value) {
    if ($definition = $this
      ->getConfigDefinition($key)) {
      $typed_data = \Drupal::typedData()
        ->create($definition, $value);
      if ($typed_data
        ->validate()
        ->count() > 0) {
        throw new PluginException("The provided configuration value does not pass validation.");
      }
    }
    $this->configuration[$key] = $value;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContextAwarePluginBase::$context protected property The data objects representing the context of this plugin.
ContextAwarePluginBase::getContext public function Implements \Drupal\Component\Plugin\ContextAwarePluginInterface::getContext(). Overrides ContextAwarePluginInterface::getContext
ContextAwarePluginBase::getContextDefinition public function Implements \Drupal\Component\Plugin\ContextAwarePluginInterface::getContextDefinition(). Overrides ContextAwarePluginInterface::getContextDefinition
ContextAwarePluginBase::getContextDefinitions public function Implements \Drupal\Component\Plugin\ContextAwarePluginInterface::getContextDefinitions(). Overrides ContextAwarePluginInterface::getContextDefinitions
ContextAwarePluginBase::getContexts public function Implements \Drupal\Component\Plugin\ContextAwarePluginInterface::getContexts(). Overrides ContextAwarePluginInterface::getContexts
ContextAwarePluginBase::getContextValue public function Implements \Drupal\Component\Plugin\ContextAwarePluginInterface::getContextValue(). Overrides ContextAwarePluginInterface::getContextValue
ContextAwarePluginBase::getContextValues public function Implements \Drupal\Component\Plugin\ContextAwarePluginInterface::getContextValues(). Overrides ContextAwarePluginInterface::getContextValues
ContextAwarePluginBase::setContextValue public function Override of \Drupal\Component\Plugin\ContextAwarePluginBase::setContextValue(). Overrides ContextAwarePluginBase::setContextValue
ContextAwarePluginBase::validateContexts public function Implements \Drupal\Component\Plugin\ContextAwarePluginInterface::valdidateContexts(). Overrides ContextAwarePluginInterface::validateContexts
ContextAwarePluginBase::__construct public function Override of \Drupal\Component\Plugin\ContextAwarePluginBase::__construct(). Overrides ContextAwarePluginBase::__construct
ExecutableInterface::execute public function Executes the plugin. 25
ExecutablePluginBase::$executableManager protected property The condition manager to proxy execute calls through.
ExecutablePluginBase::getConfig public function Gets all configuration values.
ExecutablePluginBase::getConfigDefinition public function Gets the definition of a configuration option.
ExecutablePluginBase::getConfigDefinitions public function Gets an array of definitions of available configuration options.
ExecutablePluginBase::setConfig public function Sets the value of a particular configuration option.
ExecutablePluginBase::setExecutableManager public function
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition.
PluginBase::$pluginId protected property The plugin_id.
PluginBase::getPluginDefinition public function Returns the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition
PluginBase::getPluginId public function Returns the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId