You are here

protected function LanguageNegotiationContentEntity::getContentEntityPaths in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity::getContentEntityPaths()

Returns the paths for the link templates of all content entities.

Return value

array An array of all content entity type IDs, keyed by the corresponding link template paths.

File

core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php, line 261

Class

LanguageNegotiationContentEntity
Class for identifying the content translation language.

Namespace

Drupal\language\Plugin\LanguageNegotiation

Code

protected function getContentEntityPaths() {
  if (!isset($this->contentEntityPaths)) {
    $this->contentEntityPaths = [];
    $entity_types = $this->entityTypeManager
      ->getDefinitions();
    foreach ($entity_types as $entity_type_id => $entity_type) {
      if ($entity_type
        ->entityClassImplements(ContentEntityInterface::class)) {
        $entity_paths = array_fill_keys($entity_type
          ->getLinkTemplates(), $entity_type_id);
        $this->contentEntityPaths = array_merge($this->contentEntityPaths, $entity_paths);
      }
    }
  }
  return $this->contentEntityPaths;
}