You are here

public function ServiceDefinitionEntityRequestContentBase::processRequest in Services 8.4

Same name and namespace in other branches
  1. 9.0.x src/ServiceDefinitionEntityRequestContentBase.php \Drupal\services\ServiceDefinitionEntityRequestContentBase::processRequest()

Return value

\Drupal\Core\Entity\EntityInterface|array

Overrides ServiceDefinitionInterface::processRequest

2 calls to ServiceDefinitionEntityRequestContentBase::processRequest()
EntityPost::processRequest in src/Plugin/ServiceDefinition/EntityPost.php
Processes the request and returns an array of data as appropriate.
EntityPut::processRequest in src/Plugin/ServiceDefinition/EntityPut.php
Processes the request and returns an array of data as appropriate.
2 methods override ServiceDefinitionEntityRequestContentBase::processRequest()
EntityPost::processRequest in src/Plugin/ServiceDefinition/EntityPost.php
Processes the request and returns an array of data as appropriate.
EntityPut::processRequest in src/Plugin/ServiceDefinition/EntityPut.php
Processes the request and returns an array of data as appropriate.

File

src/ServiceDefinitionEntityRequestContentBase.php, line 45

Class

ServiceDefinitionEntityRequestContentBase
Class \Drupal\services\ServiceDefinitionEntityRequestContentBase.

Namespace

Drupal\services

Code

public function processRequest(Request $request, RouteMatchInterface $route_match, SerializerInterface $serializer) {

  // Unserialize the content of the request if there is any.
  $content = $request
    ->getContent();
  if (!empty($content)) {
    $entity_type_id = $this
      ->getDerivativeId();

    /** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */
    $entity_type = $this->manager
      ->getDefinition($entity_type_id);
    return $serializer
      ->deserialize($content, $entity_type
      ->getClass(), $request
      ->getContentType(), [
      'entity_type' => $entity_type_id,
    ]);
  }
  return [];
}