function EntityRepository::getCanonical

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityRepository.php \Drupal\Core\Entity\EntityRepository::getCanonical()
  2. 8.9.x core/lib/Drupal/Core/Entity/EntityRepository.php \Drupal\Core\Entity\EntityRepository::getCanonical()
  3. 11.x core/lib/Drupal/Core/Entity/EntityRepository.php \Drupal\Core\Entity\EntityRepository::getCanonical()

File

core/lib/Drupal/Core/Entity/EntityRepository.php, line 174

Class

EntityRepository
Provides several mechanisms for retrieving entities.

Namespace

Drupal\Core\Entity

Code

public function getCanonical($entity_type_id, $entity_id, ?array $contexts = NULL) {
    return current($this->getCanonicalMultiple($entity_type_id, [
        $entity_id,
    ], $contexts)) ?: NULL;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.