You are here

public function RouteSubscriber::alterRoutes in Lightning Core 8.3

Same name and namespace in other branches
  1. 8.5 src/Routing/RouteSubscriber.php \Drupal\lightning_core\Routing\RouteSubscriber::alterRoutes()
  2. 8 src/Routing/RouteSubscriber.php \Drupal\lightning_core\Routing\RouteSubscriber::alterRoutes()
  3. 8.2 src/Routing/RouteSubscriber.php \Drupal\lightning_core\Routing\RouteSubscriber::alterRoutes()
  4. 8.4 src/Routing/RouteSubscriber.php \Drupal\lightning_core\Routing\RouteSubscriber::alterRoutes()

Alters existing routes for a specific collection.

Parameters

\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.

Overrides RouteSubscriberBase::alterRoutes

File

src/Routing/RouteSubscriber.php, line 38

Class

RouteSubscriber
Dynamically alters various routes.

Namespace

Drupal\lightning_core\Routing

Code

public function alterRoutes(RouteCollection $collection) {
  foreach ($this->entityTypeManager
    ->getDefinitions() as $id => $entity_type) {
    if ($entity_type
      ->get('field_ui_base_route') == NULL) {
      continue;
    }

    // The 'Manage fields' page.
    $this
      ->setBundleAsTitle("entity.{$id}.field_ui_fields", $collection);

    // The default view display under 'Manage display'.
    $this
      ->setBundleAsTitle("entity.entity_view_display.{$id}.default", $collection);

    // A customized view display under 'Manage display'.
    $this
      ->setBundleAsTitle("entity.entity_view_display.{$id}.view_mode", $collection);

    // The default form display under 'Manage display'.
    $this
      ->setBundleAsTitle("entity.entity_form_display.{$id}.default", $collection);

    // A customized form display under 'Manage display'.
    $this
      ->setBundleAsTitle("entity.entity_form_display.{$id}.form_mode", $collection);
  }
}