You are here

public function RouteEnhancerCollectorTrait::addRouteEnhancer in Page Manager 8.4

Same name and namespace in other branches
  1. 8 src/Routing/RouteEnhancerCollectorTrait.php \Drupal\page_manager\Routing\RouteEnhancerCollectorTrait::addRouteEnhancer()

Add route enhancers to the router to let them generate information on matched routes.

The order of the enhancers is determined by the priority, the higher the value, the earlier the enhancer is run.

Parameters

\Drupal\Core\Routing\EnhancerInterface $enhancer:

int $priority:

Return value

$this

File

src/Routing/RouteEnhancerCollectorTrait.php, line 38

Class

RouteEnhancerCollectorTrait
Provides a trait to make a service a collector of route enhancers.

Namespace

Drupal\page_manager\Routing

Code

public function addRouteEnhancer(EnhancerInterface $enhancer, $priority = 0) {
  if (empty($this->enhancers[$priority])) {
    $this->enhancers[$priority] = [];
  }
  $this->enhancers[$priority][] = $enhancer;
  $this->sortedEnhancers = [];
  return $this;
}