/** * Factory method. Returns a link binding object appropriate for the source link type. * * @param Drupal7Route $source * The source (Drupal 7) route. * @param Drupal8Route $destination * The destination (Drupal 8) route. * * @return mixed * A link binding object; either an instance of this class or a subclass thereof. */ public function create(Drupal7Route $source, Drupal8Route $destination) { if ($source->isLink()) { return new MenuLinkBinding($source, $destination); } elseif ($source->isLocalTask() || $source->isDefaultLocalTask()) { return new LocalTaskLinkBinding($source, $destination, $this->linkManager); } elseif ($source->isLocalAction()) { if ($source->isContextualLink()) { return new LinkBinding($source, $destination); } else { return new LocalActionLinkBinding($source, $destination); } } }
/** * Builds a parameter map from the aggregated arguments of the title, * access, and page callbacks. * * @return \Drupal\drupalmoduleupgrader\Routing\ParameterMap */ protected function buildParameterMap(TargetInterface $target, Drupal7Route $route) { $map = new ParameterMap(clone $route->getPath(), []); $indexer = $target->getIndexer('function'); if ($indexer->has($route['title callback'])) { $map->merge(new ParameterMap($route->getPath(), $indexer->get($route['title callback'])->getParameters()->toArray(), $route['title arguments'])); } if ($indexer->has($route['access callback'])) { $map->merge(new ParameterMap($route->getPath(), $indexer->get($route['access callback'])->getParameters()->toArray(), $route['access arguments'])); } if ($indexer->has($route['page callback'])) { $map->merge(new ParameterMap($route->getPath(), $indexer->get($route['page callback'])->getParameters()->toArray(), $route['page arguments'])); } return $map; }