function RestExport::overrideApplies

Same name and namespace in other branches
  1. 9 core/modules/rest/src/Plugin/views/display/RestExport.php \Drupal\rest\Plugin\views\display\RestExport::overrideApplies()
  2. 8.9.x core/modules/rest/src/Plugin/views/display/RestExport.php \Drupal\rest\Plugin\views\display\RestExport::overrideApplies()
  3. 10 core/modules/rest/src/Plugin/views/display/RestExport.php \Drupal\rest\Plugin\views\display\RestExport::overrideApplies()

Determines whether the view overrides the given route.

Parameters

string $view_path: The path of the view.

\Symfony\Component\Routing\Route $view_route: The route of the view.

\Symfony\Component\Routing\Route $route: The route itself.

Return value

bool TRUE, when the view should override the given route.

Overrides PathPluginBase::overrideApplies

File

core/modules/rest/src/Plugin/views/display/RestExport.php, line 387

Class

RestExport
The plugin that handles Data response callbacks for REST resources.

Namespace

Drupal\rest\Plugin\views\display

Code

protected function overrideApplies($view_path, Route $view_route, Route $route) {
    $route_has_format = $route->hasRequirement('_format');
    $route_formats = $route_has_format ? explode('|', $route->getRequirement('_format')) : [];
    $view_route_formats = $view_route->hasRequirement('_format') ? explode('|', $view_route->getRequirement('_format')) : [];
    return $this->overrideAppliesPathAndMethod($view_path, $view_route, $route) && (!$route_has_format || array_intersect($route_formats, $view_route_formats) != []);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.