public function EntityGet::processRequest in Services 9.0.x
Same name and namespace in other branches
- 8.4 src/Plugin/ServiceDefinition/EntityGet.php \Drupal\services\Plugin\ServiceDefinition\EntityGet::processRequest()
Processes the request and returns an array of data as appropriate.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request object.
\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match object.
\Symfony\Component\Serializer\SerializerInterface $serializer: The serializer. Some methods might require the plugin to leverage the serializer after extracting the request contents.
Return value
array The response.
Throws
\Symfony\Component\HttpKernel\Exception\HttpException
Overrides ServiceDefinitionInterface::processRequest
File
- src/
Plugin/ ServiceDefinition/ EntityGet.php, line 33
Class
- EntityGet
- Plugin annotation @ServiceDefinition( id = "entity_get", methods = { "GET" }, translatable = true, deriver = "\Drupal\services\Plugin\Deriver\EntityGet" )
Namespace
Drupal\services\Plugin\ServiceDefinitionCode
public function processRequest(Request $request, RouteMatchInterface $route_match, SerializerInterface $serializer) {
/* @var $entity \Drupal\Core\Entity\EntityInterface */
$entity = $this
->getContextValue($this
->getDerivativeId());
return $entity
->toArray();
}