You are here

public function RestResourceGetRouteProcessorBC::processOutbound in Drupal 8

Processes the outbound route.

Parameters

string $route_name: The route name.

\Symfony\Component\Routing\Route $route: The outbound route to process.

array $parameters: An array of parameters to be passed to the route compiler. Passed by reference.

\Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata: (optional) Object to collect route processors' bubbleable metadata.

Return value

The processed path.

Overrides OutboundRouteProcessorInterface::processOutbound

File

core/modules/rest/src/RouteProcessor/RestResourceGetRouteProcessorBC.php, line 45

Class

RestResourceGetRouteProcessorBC
Processes the BC REST routes, to ensure old route names continue to work.

Namespace

Drupal\rest\RouteProcessor

Code

public function processOutbound($route_name, Route $route, array &$parameters, BubbleableMetadata $bubbleable_metadata = NULL) {
  $route_name_parts = explode('.', $route_name);

  // BC: the REST module originally created per-format GET routes, instead
  // of a single route. To minimize the surface of this BC layer, this uses
  // route definitions that are as empty as possible, plus an outbound route
  // processor.
  // @see \Drupal\rest\Plugin\ResourceBase::routes()
  if ($route_name_parts[0] === 'rest' && $route_name_parts[count($route_name_parts) - 2] === 'GET' && in_array($route_name_parts[count($route_name_parts) - 1], $this->serializerFormats, TRUE)) {
    array_pop($route_name_parts);
    $redirected_route_name = implode('.', $route_name_parts);
    @trigger_error(sprintf("The '%s' route is deprecated since version 8.5.x and will be removed in 9.0.0. Use the '%s' route instead.", $route_name, $redirected_route_name), E_USER_DEPRECATED);
    static::overwriteRoute($route, $this->routeProvider
      ->getRouteByName($redirected_route_name));
  }
}