protected function PanelsEverywhereRouteSubscriber::alterRoutes in Panels Everywhere 8.4
File
- src/
Routing/ PanelsEverywhereRouteSubscriber.php, line 31 - Contains \Drupal\panels_everywhere\Routing\PanelsEverywhereRouteSubscriber.
Class
- PanelsEverywhereRouteSubscriber
- Associates a route with a Page Manager page, if it exists
Namespace
Drupal\panels_everywhere\RoutingCode
protected function alterRoutes(RouteCollection $collection) {
foreach ($this->entityStorage
->loadMultiple() as $entity_id => $entity) {
// If the page is disabled or if it's not set to disable route override, skip processing it.
if (!$entity
->status() || !$entity
->getVariants()) {
continue;
}
$other_variants = [];
$panels_everywhere_variant_present = FALSE;
foreach ($entity
->getVariants() as $variant_id => $variant) {
if ($variant
->getVariantPluginId() != 'panels_everywhere_variant') {
$other_variants[$variant_id] = $variant;
continue;
}
$panels_everywhere_variant_present = TRUE;
$route = $this
->getRouteAndCleanup($entity, $variant, $collection);
if (is_null($route)) {
continue;
}
$route
->setDefault('page_id', $entity
->id());
}
if ($panels_everywhere_variant_present) {
foreach ($other_variants as $variant_id => $variant) {
$variant_route = $this
->getRouteFor($entity, $variant, $collection);
if ($variant_route) {
$variant_route
->setDefault('page_id', $entity
->id());
}
}
}
}
}