You are here

abstract class RabbitHoleBehaviorPluginBase in Rabbit Hole 8

Same name and namespace in other branches
  1. 2.x src/Plugin/RabbitHoleBehaviorPluginBase.php \Drupal\rabbit_hole\Plugin\RabbitHoleBehaviorPluginBase

Base class for Rabbit hole behavior plugin plugins.

Hierarchy

Expanded class hierarchy of RabbitHoleBehaviorPluginBase

4 files declare their use of RabbitHoleBehaviorPluginBase
AccessDenied.php in src/Plugin/RabbitHoleBehaviorPlugin/AccessDenied.php
DisplayPage.php in src/Plugin/RabbitHoleBehaviorPlugin/DisplayPage.php
PageNotFound.php in src/Plugin/RabbitHoleBehaviorPlugin/PageNotFound.php
PageRedirect.php in src/Plugin/RabbitHoleBehaviorPlugin/PageRedirect.php

File

src/Plugin/RabbitHoleBehaviorPluginBase.php, line 13

Namespace

Drupal\rabbit_hole\Plugin
View source
abstract class RabbitHoleBehaviorPluginBase extends PluginBase implements RabbitHoleBehaviorPluginInterface {

  /**
   * {@inheritdoc}
   */
  public function performAction(EntityInterface $entity) {

    // Perform no action.
  }

  /**
   * {@inheritdoc}
   */
  public function settingsForm(array &$form, FormStateInterface $form_state, $form_id, EntityInterface $entity = NULL, $entity_is_bundle = FALSE, ImmutableConfig $bundle_settings = NULL) {

    // Present no settings form.
  }

  /**
   * {@inheritdoc}
   */
  public function settingsFormHandleSubmit(&$form, &$form_state) {

    // No extra action to handle submission by default.
  }

  /**
   * {@inheritdoc}
   */
  public function alterExtraFields(array &$fields) {

    // Don't change the fields by default.
  }

  /**
   * {@inheritdoc}
   */
  public function usesResponse() {
    return RabbitHoleBehaviorPluginInterface::USES_RESPONSE_NEVER;
  }

  /**
   * Returns configuration object with "Rabbit Hole" bundle settings.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity the action is being performed on.
   *
   * @return \Drupal\Core\Config\ImmutableConfig
   *   Configuration object with bundle settings.
   */
  protected function getBundleSettings(EntityInterface $entity) {
    $bundle_entity_type = $entity
      ->getEntityType()
      ->getBundleEntityType();
    return \Drupal::service('rabbit_hole.behavior_settings_manager')
      ->loadBehaviorSettingsAsConfig($bundle_entity_type ?: $entity
      ->getEntityType()
      ->id(), $bundle_entity_type ? $entity
      ->bundle() : NULL);
  }

  /**
   * Returns the fallback action in case if action cannot be performed.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity the action is being performed on.
   *
   * @return string
   *   Fallback action name.
   */
  protected function getFallbackAction(EntityInterface $entity) {
    return 'access_denied';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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 3
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.
PluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. 92
RabbitHoleBehaviorPluginBase::alterExtraFields public function Add to or adjust the fields added by rabbit hole. Overrides RabbitHoleBehaviorPluginInterface::alterExtraFields 1
RabbitHoleBehaviorPluginBase::getBundleSettings protected function Returns configuration object with "Rabbit Hole" bundle settings.
RabbitHoleBehaviorPluginBase::getFallbackAction protected function Returns the fallback action in case if action cannot be performed. 1
RabbitHoleBehaviorPluginBase::performAction public function Perform the rabbit hole action. Overrides RabbitHoleBehaviorPluginInterface::performAction 3
RabbitHoleBehaviorPluginBase::settingsForm public function Return a settings form for the rabbit hole action. Overrides RabbitHoleBehaviorPluginInterface::settingsForm 1
RabbitHoleBehaviorPluginBase::settingsFormHandleSubmit public function Handle submission of the settings form for this plugin. Overrides RabbitHoleBehaviorPluginInterface::settingsFormHandleSubmit
RabbitHoleBehaviorPluginBase::usesResponse public function Get whether this plugin uses a response to perform its action. Overrides RabbitHoleBehaviorPluginInterface::usesResponse
RabbitHoleBehaviorPluginInterface::USES_RESPONSE_ALWAYS constant
RabbitHoleBehaviorPluginInterface::USES_RESPONSE_NEVER constant
RabbitHoleBehaviorPluginInterface::USES_RESPONSE_SOMETIMES constant