You are here

trait RulesUiHandlerTrait in Rules 8.3

Trait for getting the rules_ui_handler attribute of the current request.

Note that the current route must have the _rules_ui option set for the handler being available. This is done automatically for routes generated for the rules_ui (via \Drupal\rules\Routing\RulesUiRouteSubscriber).

Hierarchy

3 files declare their use of RulesUiHandlerTrait
ActionForm.php in src/Form/Expression/ActionForm.php
ConditionForm.php in src/Form/Expression/ConditionForm.php
ExpressionContainerFormBase.php in src/Form/Expression/ExpressionContainerFormBase.php

File

src/Ui/RulesUiHandlerTrait.php, line 12

Namespace

Drupal\rules\Ui
View source
trait RulesUiHandlerTrait {

  /**
   * The rules UI handler.
   *
   * @var \Drupal\rules\Ui\RulesUiHandlerInterface
   */
  protected $rulesUiHandler;

  /**
   * Gets the rules UI handler of the current route.
   *
   * @return \Drupal\rules\Ui\RulesUiHandlerInterface|null
   *   The handler, or NULL if this is no rules_ui enabled route.
   */
  public function getRulesUiHandler() {
    if (!isset($this->rulesUiHandler)) {
      $this->rulesUiHandler = \Drupal::request()->attributes
        ->get('rules_ui_handler');
    }
    return $this->rulesUiHandler;
  }

  /**
   * Sets the Rules UI handler.
   *
   * @param \Drupal\rules\Ui\RulesUiHandlerInterface $rules_ui_handler
   *   The Rules UI handler to set.
   *
   * @return $this
   */
  public function setRulesUiHandler(RulesUiHandlerInterface $rules_ui_handler) {
    $this->rulesUiHandler = $rules_ui_handler;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RulesUiHandlerTrait::$rulesUiHandler protected property The rules UI handler.
RulesUiHandlerTrait::getRulesUiHandler public function Gets the rules UI handler of the current route.
RulesUiHandlerTrait::setRulesUiHandler public function Sets the Rules UI handler.