You are here

class RulesUiRouteEnhancer in Rules 8.3

Enhances routes with the specified RulesUI.

Routes have the plugin ID of the active RulesUI instance set on the _rules_ui option. Based upon that information, this enhances adds the following parameters to the routes:

  • rules_ui_handler: The RulesUI handler, as specified by the plugin.
  • rules_component: The rules component being edited, as provided by the handler.

Hierarchy

Expanded class hierarchy of RulesUiRouteEnhancer

1 string reference to 'RulesUiRouteEnhancer'
rules.services.yml in ./rules.services.yml
rules.services.yml
1 service uses RulesUiRouteEnhancer
rules.ui_route_enhancer in ./rules.services.yml
Drupal\rules\Routing\RulesUiRouteEnhancer

File

src/Routing/RulesUiRouteEnhancer.php, line 20

Namespace

Drupal\rules\Routing
View source
class RulesUiRouteEnhancer implements EnhancerInterface {

  /**
   * The rules_ui plugin manager.
   *
   * @var \Drupal\rules\Ui\RulesUiManagerInterface
   */
  protected $rulesUiManager;

  /**
   * Constructs the object.
   *
   * @param \Drupal\rules\Ui\RulesUiManagerInterface $rules_ui_manager
   *   The rules_ui plugin manager.
   */
  public function __construct(RulesUiManagerInterface $rules_ui_manager) {
    $this->rulesUiManager = $rules_ui_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function enhance(array $defaults, Request $request) {

    /** @var \Symfony\Component\Routing\Route $route */
    $route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
    if ($plugin_id = $route
      ->getOption('_rules_ui')) {
      $defaults['rules_ui_handler'] = $this->rulesUiManager
        ->createInstance($plugin_id);
    }
    return $defaults;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RulesUiRouteEnhancer::$rulesUiManager protected property The rules_ui plugin manager.
RulesUiRouteEnhancer::enhance public function Update the defaults based on its own data and the request.
RulesUiRouteEnhancer::__construct public function Constructs the object.