function EntityRepository::getActive

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

Overrides EntityRepositoryInterface::getActive

File

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

Class

EntityRepository
Provides several mechanisms for retrieving entities.

Namespace

Drupal\Core\Entity

Code

public function getActive($entity_type_id, $entity_id, array $contexts = NULL) {
    return current($this->getActiveMultiple($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.