You are here

class EntityTypeDeriver in GraphQL 8.3

Same name in this branch
  1. 8.3 modules/graphql_core/src/Plugin/Deriver/Interfaces/EntityTypeDeriver.php \Drupal\graphql_core\Plugin\Deriver\Interfaces\EntityTypeDeriver
  2. 8.3 modules/graphql_core/src/Plugin/Deriver/Types/EntityTypeDeriver.php \Drupal\graphql_core\Plugin\Deriver\Types\EntityTypeDeriver

Hierarchy

Expanded class hierarchy of EntityTypeDeriver

File

modules/graphql_core/src/Plugin/Deriver/Types/EntityTypeDeriver.php, line 10

Namespace

Drupal\graphql_core\Plugin\Deriver\Types
View source
class EntityTypeDeriver extends EntityTypeDeriverBase {
  use StringTranslationTrait;

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($basePluginDefinition) {
    foreach ($this->entityTypeManager
      ->getDefinitions() as $typeId => $type) {
      if (!$type instanceof ContentEntityTypeInterface) {
        continue;
      }

      // Create the entity type only for types that do not support bundles. For
      // all others, we create common interfaces instead.
      if ($type
        ->hasKey('bundle')) {
        continue;
      }
      $derivative = [
        'name' => StringHelper::camelCase($typeId),
        'description' => $this
          ->t("The '@type' entity type.", [
          '@type' => $type
            ->getLabel(),
        ]),
        'type' => "entity:{$typeId}",
        'interfaces' => $this
          ->getInterfaces($type, $basePluginDefinition),
        'entity_type' => $typeId,
      ] + $basePluginDefinition;
      $this->derivatives[$typeId] = $derivative;
    }
    return parent::getDerivativeDefinitions($basePluginDefinition);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
EntityTypeDeriver::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
EntityTypeDeriverBase::$entityTypeBundleInfo protected property Bundle info manager.
EntityTypeDeriverBase::$entityTypeManager protected property The entity type manager.
EntityTypeDeriverBase::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
EntityTypeDeriverBase::getInterfaces protected function Retrieve the interfaces that the entity type should implement.
EntityTypeDeriverBase::__construct public function EntityTypeDeriver constructor.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.