You are here

interface RulesConfigurableEventHandlerInterface in Rules 8.3

Interface for handling configurable rules events.

Configurable events have a custom event suffix, which gets appended to the base event name (= the plugin id), forming the fully-qualified event name, which is used for triggering reaction rules.

For example, the fully-qualified event name of an event for viewing an article node would be "rules_entity_view:node--article", whereas "rules_entity_view:node" is the base event name and "article" the event suffix as returned from ::getEventNameSuffix().

The event name suffix must be generated from the event data at run-time, while the configured plugin has to determine it based upon the event configuration.

Hierarchy

Expanded class hierarchy of RulesConfigurableEventHandlerInterface

All classes that implement RulesConfigurableEventHandlerInterface

See also

\Drupal\rules\Core\RulesDefaultEventHandler

3 files declare their use of RulesConfigurableEventHandlerInterface
ConfigurableEventHandlerBase.php in src/EventHandler/ConfigurableEventHandlerBase.php
GenericEventSubscriber.php in src/EventSubscriber/GenericEventSubscriber.php
ReactionRuleAddForm.php in src/Form/ReactionRuleAddForm.php

File

src/Core/RulesConfigurableEventHandlerInterface.php, line 27

Namespace

Drupal\rules\Core
View source
interface RulesConfigurableEventHandlerInterface extends RulesEventHandlerInterface, ConfigurableInterface {

  /**
   * Determines the qualified event names for the dispatched event.
   *
   * @param \Symfony\Component\EventDispatcher\Event $event
   *   The event data of the event being dispatched.
   * @param string $event_name
   *   The event base name.
   * @param array $event_definition
   *   The event definition. If necessary for the event, the contained context
   *   definitions may be refined as suiting for the event data.
   *
   * @return string[]
   *   The array of qualified event name suffixes to add; e.g, 'article' if
   *   the fully-qualified event "rules_entity_view:node--article" should be
   *   triggered in addition to base event "rules_entity_view:node".
   */
  public static function determineQualifiedEvents(Event $event, $event_name, array &$event_definition);

  /**
   * Provides a human readable summary of the event's configuration.
   *
   * @return string|\Drupal\Component\Render\MarkupInterface
   *   The human readable summary.
   */
  public function summary();

  /**
   * Builds the event configuration form.
   *
   * @param array $form
   *   An associative array containing the initial structure of the plugin form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the complete form.
   *
   * @return array
   *   The form structure.
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state);

  /**
   * Extract the form values and update the event configuration.
   *
   * @param array $form
   *   An associative array containing the structure of the plugin form as built
   *   by static::buildConfigurationForm().
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the complete form.
   */
  public function extractConfigurationFormValues(array &$form, FormStateInterface $form_state);

  /**
   * Validates that this event is configured correctly.
   *
   * @return \Drupal\rules\Engine\IntegrityViolationList
   *   A list object containing \Drupal\rules\Engine\IntegrityViolation objects.
   */
  public function validate();

  /**
   * Provides the event name suffix based upon the plugin configuration.
   *
   * If the event is configured and a suffix is provided, the event name Rules
   * uses for the configured event is {EVENT_NAME}--{SUFFIX}.
   *
   * @return string|false
   *   The suffix string, for FALSE if no suffix should be appended.
   */
  public function getEventNameSuffix();

  /**
   * Refines provided context definitions based upon plugin configuration.
   */
  public function refineContextDefinitions();

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigurableInterface::defaultConfiguration public function Gets default configuration for this plugin. 11
ConfigurableInterface::getConfiguration public function Gets this plugin's configuration. 12
ConfigurableInterface::setConfiguration public function Sets the configuration for this plugin instance. 12
DerivativeInspectionInterface::getBaseId public function Gets the base_plugin_id of the plugin instance. 1
DerivativeInspectionInterface::getDerivativeId public function Gets the derivative_id of the plugin instance. 1
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 4
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2
RulesConfigurableEventHandlerInterface::buildConfigurationForm public function Builds the event configuration form. 1
RulesConfigurableEventHandlerInterface::determineQualifiedEvents public static function Determines the qualified event names for the dispatched event. 1
RulesConfigurableEventHandlerInterface::extractConfigurationFormValues public function Extract the form values and update the event configuration. 1
RulesConfigurableEventHandlerInterface::getEventNameSuffix public function Provides the event name suffix based upon the plugin configuration. 1
RulesConfigurableEventHandlerInterface::refineContextDefinitions public function Refines provided context definitions based upon plugin configuration. 1
RulesConfigurableEventHandlerInterface::summary public function Provides a human readable summary of the event's configuration. 1
RulesConfigurableEventHandlerInterface::validate public function Validates that this event is configured correctly. 1
RulesEventHandlerInterface::getContextDefinition public function Gets a specific context definition of the plugin. 1
RulesEventHandlerInterface::getContextDefinitions public function Gets the context definitions of the event. 1