You are here

protected function DisplayModeIdDeriver::getDisplayModes in GraphQL 8.3

Retrieves a list of entity view modes grouped by their target type.

Return value

array The list of entity view modes grouped by the target entity type.

1 call to DisplayModeIdDeriver::getDisplayModes()
DisplayModeIdDeriver::getDerivativeDefinitions in modules/graphql_core/src/Plugin/Deriver/Enums/DisplayModeIdDeriver.php
Gets the definition of all derivatives of a base plugin.

File

modules/graphql_core/src/Plugin/Deriver/Enums/DisplayModeIdDeriver.php, line 63

Class

DisplayModeIdDeriver

Namespace

Drupal\graphql_core\Plugin\Deriver\Enums

Code

protected function getDisplayModes() {
  $storage = $this->entityTypeManager
    ->getStorage('entity_view_mode');
  return array_reduce($storage
    ->loadMultiple(), function ($carry, EntityViewModeInterface $current) {
    $target = $current
      ->getTargetType();
    list(, $id) = explode('.', $current
      ->id());
    $carry[$target][StringHelper::upperCase($id)] = [
      'value' => $id,
      'description' => $this
        ->t("The '@label' display mode for '@type' entities.", [
        '@label' => $current
          ->label(),
        '@type' => $this->entityTypeManager
          ->getDefinition($target)
          ->getLabel(),
      ]),
    ];
    return $carry;
  }, []);
}