You are here

public function EntityDelete::processRequest in Services 8.4

Same name and namespace in other branches
  1. 9.0.x src/Plugin/ServiceDefinition/EntityDelete.php \Drupal\services\Plugin\ServiceDefinition\EntityDelete::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/EntityDelete.php, line 33

Class

EntityDelete
Plugin annotation @ServiceDefinition( id = "entity_delete", methods = { "DELETE" }, translatable = true, deriver = "\Drupal\services\Plugin\Deriver\EntityDelete" )

Namespace

Drupal\services\Plugin\ServiceDefinition

Code

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

  /** @var \Drupal\Core\Entity\EntityInterface $entity */
  $entity = $this
    ->getContextValue($this
    ->getDerivativeId());
  $entity
    ->delete();
}