processRoute example


  public function getOverviewRoute() {
    $route = new Route(
      $this->getBaseRoute()->getPath() . '/translate',
      [
        '_controller' => '\Drupal\config_translation\Controller\ConfigTranslationController::itemPage',
        'plugin_id' => $this->getPluginId(),
      ],
      ['_config_translation_overview_access' => 'TRUE']
    );
    $this->processRoute($route);
    return $route;
  }

  /** * {@inheritdoc} */
  public function getOverviewPath() {
    return Url::fromRoute($this->getOverviewRouteName()$this->getOverviewRouteParameters())->getInternalPath();
  }

  /** * {@inheritdoc} */


  /** * {@inheritdoc} */
  public function getPathFromRoute($name$parameters = []) {
    $route = $this->getRoute($name);
    if (!is_string($name)) {
      @trigger_error('Passing a route object to ' . __METHOD__ . '() is deprecated in drupal:10.1.0 and will not be supported in drupal:11.0.0. Pass the route name instead. See https://www.drupal.org/node/3172280', E_USER_DEPRECATED);
      $name = $this->getRouteStringIdentifier($name);
    }
    $this->processRoute($name$route$parameters);
    $path = $this->getInternalPathFromRoute($name$route$parameters);
    // Router-based paths may have a querystring on them but Drupal paths may     // not have one, so remove any ? and anything after it. For generate() this     // is handled in processPath().     $path = preg_replace('/\?.*/', '', $path);
    return trim($path, '/');
  }

  /** * Substitute the route parameters into the route path. * * Note: This code was copied from * \Symfony\Component\Routing\Generator\UrlGenerator::doGenerate() and * shortened by removing code that is not relevant to Drupal or that is * handled separately in ::generateFromRoute(). The Symfony version should be * examined for changes in new Symfony releases. * * @param array $variables * The variables from the compiled route, corresponding to slugs in the * route path. * @param array $defaults * The defaults from the route. * @param array $tokens * The tokens from the compiled route. * @param array $parameters * The route parameters passed to the generator. Parameters that do not * match any variables will be added to the result as query parameters. * @param array $query_params * Query parameters passed to the generator as $options['query']. This may * be modified if there are extra parameters not used as route variables. * @param string $name * The route name. * * @return string * The URL path, without any base path, without the query string, not URL * encoded. * * @throws \Symfony\Component\Routing\Exception\MissingMandatoryParametersException * When some parameters are missing that are mandatory for the route. * @throws \Symfony\Component\Routing\Exception\InvalidParameterException * When a parameter value for a placeholder is not correct because it does * not match the requirement. */
Home | Imprint | This part of the site doesn't use cookies.