protected function getRoutesForResourceConfig(RestResourceConfigInterface
$rest_resource_config) { $plugin =
$rest_resource_config->
getResourcePlugin();
$collection =
new RouteCollection();
foreach ($plugin->
routes() as $name =>
$route) { /** @var \Symfony\Component\Routing\Route $route */
// @todo: Are multiple methods possible here?
$methods =
$route->
getMethods();
// Only expose routes that have an explicit method and allow >=1 format
// for that method.
if (($methods && ($method =
$methods[0
]) &&
$rest_resource_config->
getFormats($method))) { $route->
setRequirement('_csrf_request_header_token', 'TRUE'
);
// Check that authentication providers are defined.
if (empty($rest_resource_config->
getAuthenticationProviders($method))) { $this->logger->
error('At least one authentication provider must be defined for resource @id',
['@id' =>
$rest_resource_config->
id()]);
continue;
} // Check that formats are defined.
if (empty($rest_resource_config->
getFormats($method))) { $this->logger->
error('At least one format must be defined for resource @id',
['@id' =>
$rest_resource_config->
id()]);
continue;
}