You are here

public function ContentRoute::buildRouteDefinition in Drupal 7 to 8/9 Module Upgrader 8

Builds the Drupal 8 definition for the route, without making any changes to the original module or callback.

Return value

Drupal8\RouteWrapper

Overrides RouteConverterInterface::buildRouteDefinition

2 calls to ContentRoute::buildRouteDefinition()
ContentRoute::buildRoute in src/Plugin/DMU/Routing/ContentRoute.php
Builds the Drupal 8 route, making any needed changes to the original module and/or callback.
FormRoute::buildRouteDefinition in src/Plugin/DMU/Routing/FormRoute.php
Builds the Drupal 8 definition for the route, without making any changes to the original module or callback.
1 method overrides ContentRoute::buildRouteDefinition()
FormRoute::buildRouteDefinition in src/Plugin/DMU/Routing/FormRoute.php
Builds the Drupal 8 definition for the route, without making any changes to the original module or callback.

File

src/Plugin/DMU/Routing/ContentRoute.php, line 127

Class

ContentRoute
Plugin annotation @Converter( id = "default", description = @Translation("Converts a menu item to a _controller route."), dependencies = { "router.route_provider", "plugin.manager.drupalmoduleupgrader.rewriter" } )

Namespace

Drupal\drupalmoduleupgrader\Plugin\DMU\Routing

Code

public function buildRouteDefinition(TargetInterface $target, Drupal7Route $route) {
  $indexer = $target
    ->getIndexer('function');
  $definition = new CoreRoute('');
  $this
    ->buildParameterMap($target, $route)
    ->applyRoute($definition);
  $controller = $this
    ->getController($target, $route)
    ->getName()
    ->getAbsolutePath();
  if ($route
    ->containsKey('title')) {
    $definition
      ->setDefault('_title', $route['title']);
  }
  elseif ($indexer
    ->has($route['title callback'])) {
    $definition
      ->setDefault('_title_callback', $controller . '::' . $route['title callback']);
  }
  if ($route
    ->isAbsoluteAccess()) {
    $definition
      ->setRequirement('_access', $route['access callback'] ? 'true' : 'false');
  }
  elseif ($route
    ->isPermissionBased()) {
    $definition
      ->setRequirement('_permission', $route['access arguments'][0]);
  }
  elseif ($indexer
    ->has($route['access callback'])) {
    $definition
      ->setRequirement('_custom_access', $controller . '::' . $route['access callback']);
  }
  if ($indexer
    ->has($route['page callback'])) {
    $definition
      ->setDefault('_controller', $controller . '::' . $route['page callback']);
  }
  return new Drupal8Route($this
    ->getName($target, $route), $definition, $this->routeProvider);
}