You are here

abstract class RecipientTypeBase in Workbench Email 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/RecipientTypeBase.php \Drupal\workbench_email\Plugin\RecipientTypeBase

Provides a base class for Recipient type plugins.

Hierarchy

Expanded class hierarchy of RecipientTypeBase

See also

\Drupal\workbench_email\Annotation\RecipientType

\Drupal\workbench_email\RecipientTypeManager

\Drupal\workbench_email\Plugin\RecipientTypeInterface

Plugin API

5 files declare their use of RecipientTypeBase
Author.php in src/Plugin/RecipientType/Author.php
EmailField.php in src/Plugin/RecipientType/EmailField.php
FixedEmail.php in src/Plugin/RecipientType/FixedEmail.php
LastRevisionAuthor.php in src/Plugin/RecipientType/LastRevisionAuthor.php
Role.php in src/Plugin/RecipientType/Role.php

File

src/Plugin/RecipientTypeBase.php, line 19

Namespace

Drupal\workbench_email\Plugin
View source
abstract class RecipientTypeBase extends PluginBase implements RecipientTypeInterface {
  use PluginWithFormsTrait;

  /**
   * The name of the provider that owns this recipient type.
   *
   * @var string
   */
  public $provider;

  /**
   * A Boolean indicating whether this recipient type is enabled.
   *
   * @var bool
   */
  public $status = FALSE;

  /**
   * An associative array containing the configured settings of this recipient type.
   *
   * @var array
   */
  public $settings = [];

  /**
   * {@inheritdoc}
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->provider = $this->pluginDefinition['provider'];
    $this
      ->setConfiguration($configuration);
  }

  /**
   * {@inheritdoc}
   */
  public function setConfiguration(array $configuration) {
    if (isset($configuration['status'])) {
      $this->status = (bool) $configuration['status'];
    }
    if (isset($configuration['settings'])) {
      $this->settings = (array) $configuration['settings'];
    }
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getConfiguration() {
    return [
      'id' => $this
        ->getPluginId(),
      'provider' => $this->pluginDefinition['provider'],
      'status' => $this->status,
      'settings' => $this->settings,
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'provider' => $this->pluginDefinition['provider'],
      'status' => FALSE,
      'settings' => $this->pluginDefinition['settings'],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function calculateDependencies() {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function getLabel() {
    return $this->pluginDefinition['title'];
  }

  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    return $this->pluginDefinition['description'];
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function prepareRecipients(ContentEntityInterface $entity, TemplateInterface $template) {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {

    // Nil op.
  }

  /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {

    // Nil op.
  }

  /**
   * {@inheritdoc}
   */
  public function isEnabled() {
    return $this->status;
  }

  /**
   * {@inheritdoc}
   */
  public function onDependencyRemoval(array $dependencies) {
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 2
DependencySerializationTrait::__wakeup public function 2
MessengerTrait::$messenger protected property The messenger. 27
MessengerTrait::messenger public function Gets the messenger. 27
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 2
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginWithFormsTrait::getFormClass public function Implements \Drupal\Core\Plugin\PluginWithFormsInterface::getFormClass().
PluginWithFormsTrait::hasFormClass public function Implements \Drupal\Core\Plugin\PluginWithFormsInterface::hasFormClass().
RecipientTypeBase::$provider public property The name of the provider that owns this recipient type.
RecipientTypeBase::$settings public property An associative array containing the configured settings of this recipient type.
RecipientTypeBase::$status public property A Boolean indicating whether this recipient type is enabled.
RecipientTypeBase::buildConfigurationForm public function Generates a recipient types's settings form. Overrides RecipientTypeInterface::buildConfigurationForm 3
RecipientTypeBase::calculateDependencies public function Calculates dependencies for the configured plugin. Overrides DependentPluginInterface::calculateDependencies 2
RecipientTypeBase::defaultConfiguration public function Gets default configuration for this plugin. Overrides ConfigurableInterface::defaultConfiguration
RecipientTypeBase::getConfiguration public function Gets this plugin's configuration. Overrides ConfigurableInterface::getConfiguration
RecipientTypeBase::getDescription public function Returns the administrative description for this recipient type plugin. Overrides RecipientTypeInterface::getDescription
RecipientTypeBase::getLabel public function Returns the administrative label for this recipient type plugin. Overrides RecipientTypeInterface::getLabel
RecipientTypeBase::isEnabled public function Checks status. Overrides RecipientTypeInterface::isEnabled
RecipientTypeBase::onDependencyRemoval public function Informs the plugin that a dependency of the recipient type will be deleted. Overrides RecipientTypeInterface::onDependencyRemoval 2
RecipientTypeBase::prepareRecipients public function Returns email address(s) matching this recipient type's configuration. Overrides RecipientTypeInterface::prepareRecipients 5
RecipientTypeBase::setConfiguration public function Sets the configuration for this plugin instance. Overrides ConfigurableInterface::setConfiguration
RecipientTypeBase::submitConfigurationForm public function Form submission handler. Overrides PluginFormInterface::submitConfigurationForm 3
RecipientTypeBase::validateConfigurationForm public function Form validation handler. Overrides PluginFormInterface::validateConfigurationForm
RecipientTypeBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase::__construct 2
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.