You are here

class RngRouteEnhancer in RNG - Events and Registrations 8

Same name and namespace in other branches
  1. 8.2 src/Routing/Enhancer/RngRouteEnhancer.php \Drupal\rng\Routing\Enhancer\RngRouteEnhancer
  2. 3.x src/Routing/Enhancer/RngRouteEnhancer.php \Drupal\rng\Routing\Enhancer\RngRouteEnhancer

Route enhancer for RNG.

Hierarchy

Expanded class hierarchy of RngRouteEnhancer

1 string reference to 'RngRouteEnhancer'
rng.services.yml in ./rng.services.yml
rng.services.yml
1 service uses RngRouteEnhancer
rng.route_enhancer in ./rng.services.yml
Drupal\rng\Routing\Enhancer\RngRouteEnhancer

File

src/Routing/Enhancer/RngRouteEnhancer.php, line 12

Namespace

Drupal\rng\Routing\Enhancer
View source
class RngRouteEnhancer implements RouteEnhancerInterface {

  /**
   * {@inheritdoc}
   */
  public function applies(Route $route) {
    return $route
      ->hasRequirement('_entity_is_event') && $route
      ->hasDefault('event');
  }

  /**
   * {@inheritdoc}
   */
  public function enhance(array $defaults, Request $request) {
    $event_entity_type = $defaults['event'];
    if (isset($defaults[$event_entity_type])) {
      $rng_event = $defaults[$event_entity_type];
      $defaults['rng_event'] = $rng_event;
    }
    return $defaults;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RngRouteEnhancer::applies public function Declares if the route enhancer applies to the given route. Overrides RouteEnhancerInterface::applies
RngRouteEnhancer::enhance public function Update the defaults based on its own data and the request.