You are here

public function ActiveEntity::get in Configuration selector 8

Same name and namespace in other branches
  1. 8.2 src/ActiveEntity.php \Drupal\config_selector\ActiveEntity::get()

Gets the active entity from the entity type and config_selector feature.

Parameters

string $entity_type_id: The entity type to get the ID for.

string $feature: The config selector feature to get the ID for.

Return value

\Drupal\Core\Entity\EntityInterface|null The active entity for the provided entity type and feature. NULL is there is no corresponding entity.

1 call to ActiveEntity::get()
ActiveEntity::getFromEntity in src/ActiveEntity.php
Gets the active entity from using the details from an entity.

File

src/ActiveEntity.php, line 43

Class

ActiveEntity
Helper for getting the active entity or ID of any config_selector feature.

Namespace

Drupal\config_selector

Code

public function get($entity_type_id, $feature) {
  $entity_storage = $this->entityTypeManager
    ->getStorage($entity_type_id);
  $matching_config = $entity_storage
    ->getQuery()
    ->condition('third_party_settings.config_selector.feature', $feature)
    ->condition('status', FALSE, '<>')
    ->execute();
  $config_entities = $entity_storage
    ->loadMultiple($matching_config);
  $config_entities = $this
    ->sortConfigEntities($config_entities);
  return array_pop($config_entities);
}