function EntityLastInstalledSchemaRepository::getLastInstalledDefinitions

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityLastInstalledSchemaRepository.php \Drupal\Core\Entity\EntityLastInstalledSchemaRepository::getLastInstalledDefinitions()
  2. 10 core/lib/Drupal/Core/Entity/EntityLastInstalledSchemaRepository.php \Drupal\Core\Entity\EntityLastInstalledSchemaRepository::getLastInstalledDefinitions()
  3. 11.x core/lib/Drupal/Core/Entity/EntityLastInstalledSchemaRepository.php \Drupal\Core\Entity\EntityLastInstalledSchemaRepository::getLastInstalledDefinitions()

Overrides EntityLastInstalledSchemaRepositoryInterface::getLastInstalledDefinitions

File

core/lib/Drupal/Core/Entity/EntityLastInstalledSchemaRepository.php, line 40

Class

EntityLastInstalledSchemaRepository
Provides a repository for installed entity definitions.

Namespace

Drupal\Core\Entity

Code

public function getLastInstalledDefinitions() {
    $all_definitions = $this->keyValueFactory
        ->get('entity.definitions.installed')
        ->getAll();
    // Filter out field storage definitions.
    $filtered_keys = array_filter(array_keys($all_definitions), function ($key) {
        return substr($key, -12) === '.entity_type';
    });
    $entity_type_definitions = array_intersect_key($all_definitions, array_flip($filtered_keys));
    // Ensure that the returned array is keyed by the entity type ID.
    $keys = array_keys($entity_type_definitions);
    $keys = array_map(function ($key) {
        $parts = explode('.', $key);
        return $parts[0];
    }, $keys);
    return array_combine($keys, $entity_type_definitions);
}

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