public function PathProcessorEntityResourceBC::processInbound in Drupal 8
Processes the inbound path.
Implementations may make changes to the request object passed in but should avoid all other side effects. This method can be called to process requests other than the current request.
Parameters
string $path: The path to process, with a leading slash.
\Symfony\Component\HttpFoundation\Request $request: The HttpRequest object representing the request to process. Note, if this method is being called via the path_processor_manager service and is not part of routing, the current request object must be cloned before being passed in.
Return value
string The processed path.
Overrides InboundPathProcessorInterface::processInbound
File
- core/
modules/ rest/ src/ PathProcessor/ PathProcessorEntityResourceBC.php, line 34
Class
- PathProcessorEntityResourceBC
- Path processor to maintain BC for entity REST resource URLs from Drupal 8.0.
Namespace
Drupal\rest\PathProcessorCode
public function processInbound($path, Request $request) {
if ($request
->getMethod() === 'POST' && strpos($path, '/entity/') === 0) {
$parts = explode('/', $path);
$entity_type_id = array_pop($parts);
// Until Drupal 8.3, no entity types specified a link template for the
// 'create' link relation type. As of Drupal 8.3, all core content entity
// types provide this link relation type. This inbound path processor
// provides automatic backwards compatibility: it allows both the old
// default from \Drupal\rest\Plugin\rest\resource\EntityResource, i.e.
// "/entity/{entity_type}" and the link template specified in a particular
// entity type. The former is rewritten to the latter
// specific one if it exists.
$entity_type = $this->entityTypeManager
->getDefinition($entity_type_id);
if ($entity_type
->hasLinkTemplate('create')) {
return $entity_type
->getLinkTemplate('create');
}
}
return $path;
}