function EntityResource::getBaseRoute
Same name in other branches
- 9 core/modules/rest/src/Plugin/rest/resource/EntityResource.php \Drupal\rest\Plugin\rest\resource\EntityResource::getBaseRoute()
- 8.9.x core/modules/rest/src/Plugin/rest/resource/EntityResource.php \Drupal\rest\Plugin\rest\resource\EntityResource::getBaseRoute()
- 11.x core/modules/rest/src/Plugin/rest/resource/EntityResource.php \Drupal\rest\Plugin\rest\resource\EntityResource::getBaseRoute()
Overrides ResourceBase::getBaseRoute
File
-
core/
modules/ rest/ src/ Plugin/ rest/ resource/ EntityResource.php, line 369
Class
- EntityResource
- Represents entities as resources.
Namespace
Drupal\rest\Plugin\rest\resourceCode
protected function getBaseRoute($canonical_path, $method) {
$route = parent::getBaseRoute($canonical_path, $method);
switch ($method) {
case 'GET':
$route->setRequirement('_entity_access', $this->entityType
->id() . '.view');
break;
case 'POST':
$route->setRequirement('_entity_create_any_access', $this->entityType
->id());
$route->setOption('_ignore_create_bundle_access', TRUE);
break;
case 'PATCH':
$route->setRequirement('_entity_access', $this->entityType
->id() . '.update');
break;
case 'DELETE':
$route->setRequirement('_entity_access', $this->entityType
->id() . '.delete');
break;
}
$definition = $this->getPluginDefinition();
$parameters = $route->getOption('parameters') ?: [];
$parameters[$definition['entity_type']]['type'] = 'entity:' . $definition['entity_type'];
$route->setOption('parameters', $parameters);
return $route;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.