interface RulesConfigurableEventHandlerInterface

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

4 files declare their use of RulesConfigurableEventHandlerInterface
AddEventForm.php in src/Form/AddEventForm.php
AddEventFormTrait.php in src/Form/AddEventFormTrait.php
ConfigurableEventHandlerBase.php in src/EventHandler/ConfigurableEventHandlerBase.php
GenericEventSubscriber.php in src/EventSubscriber/GenericEventSubscriber.php

File

src/Core/RulesConfigurableEventHandlerInterface.php, line 26

Namespace

Drupal\rules\Core
View source
interface RulesConfigurableEventHandlerInterface extends RulesEventHandlerInterface, ConfigurableInterface {
    
    /**
     * Determines the qualified event names for the dispatched event.
     *
     * @todo The 'object' type hint should be replaced with the appropriate
     * class once Symfony 4 is no longer supported.
     *
     * @param object $event
     *   The event data of the event being dispatched.
     *   In Drupal 9 this will be a \Symfony\Component\EventDispatcher\Event,
     *   In Drupal 10 this will be a \Symfony\Contracts\EventDispatcher\Event.
     * @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(object $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

Title Sort descending Modifiers Object type Summary Overrides
ConfigurableInterface::defaultConfiguration public function Gets default configuration for this plugin. 14
ConfigurableInterface::getConfiguration public function Gets this plugin's configuration. 15
ConfigurableInterface::setConfiguration public function Sets the configuration for this plugin instance. 15
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. 6
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