getPathWithoutDefaults example


  protected function overrideAppliesPathAndMethod($view_path, Route $view_route, Route $route) {
    // Find all paths which match the path of the current display..     $route_path = RouteCompiler::getPathWithoutDefaults($route);
    $route_path = RouteCompiler::getPatternOutline($route_path);

    // Ensure that we don't override a route which is already controlled by     // views.     return !$route->hasDefault('view_id')
    && ('/' . $view_path == $route_path)
    // Also ensure that we don't override for example REST routes.     && (!$route->getMethods() || in_array('GET', $route->getMethods()));
  }

  /** * {@inheritdoc} */

  public static function compile(Route $route): CompiledRoute {
    // Symfony 4 requires that all UTF-8 route patterns have the "utf8" option     // set and Drupal does not support non UTF-8 routes.     $route->setOption('utf8', TRUE);
    $symfony_compiled = parent::compile($route);

    // The Drupal-specific compiled information.     $stripped_path = static::getPathWithoutDefaults($route);
    $fit = static::getFit($stripped_path);
    $pattern_outline = static::getPatternOutline($stripped_path);
    // We count the number of parts including any optional trailing parts. This     // allows the RouteProvider to filter candidate routes more efficiently.     $num_parts = count(explode('/', trim($route->getPath(), '/')));

    return new CompiledRoute(
      $fit,
      $pattern_outline,
      $num_parts,

      
Home | Imprint | This part of the site doesn't use cookies.