You are here

protected function AddReminder::modifyCreatedEntity in JSON:API Resources 8

Modifies the created entity before it is saved.

This method can be overridden so that custom JSON:API resources can modify the created entity before it is saved.

Classes overriding this method have access to the same arguments as a JSON:API resource's process() method by calling $request->arguments->get($arg_name).

Parameters

\Drupal\Core\Entity\EntityInterface $created_entity: The created entity.

\Symfony\Component\HttpFoundation\Request $request: The request object.

Overrides EntityCreationTrait::modifyCreatedEntity

File

tests/modules/jsonapi_resources_test/src/Resource/AddReminder.php, line 75

Class

AddReminder
Processes a request to create a reminder node for a user.

Namespace

Drupal\jsonapi_resources_test\Resource

Code

protected function modifyCreatedEntity(EntityInterface $created_entity, Request $request) {
  assert($created_entity instanceof NodeInterface);
  $created_entity
    ->setOwnerId($this->currentUser
    ->id());
}