You are here

protected function EntityResource::entityExists in JSON:API 8

Same name and namespace in other branches
  1. 8.2 src/Controller/EntityResource.php \Drupal\jsonapi\Controller\EntityResource::entityExists()

Checks if the given entity exists.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for which to test existence.

Return value

bool Whether the entity already has been created.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

1 call to EntityResource::entityExists()
EntityResource::createIndividual in src/Controller/EntityResource.php
Creates an individual entity.

File

src/Controller/EntityResource.php, line 1113

Class

EntityResource
Process all entity requests.

Namespace

Drupal\jsonapi\Controller

Code

protected function entityExists(EntityInterface $entity) {
  $entity_storage = $this->entityTypeManager
    ->getStorage($entity
    ->getEntityTypeId());
  return !empty($entity_storage
    ->loadByProperties([
    'uuid' => $entity
      ->uuid(),
  ]));
}