You are here

abstract class EntityTypeDeriverBase in GraphQL 8.3

Hierarchy

Expanded class hierarchy of EntityTypeDeriverBase

3 files declare their use of EntityTypeDeriverBase
EntityBundleDeriver.php in modules/graphql_core/src/Plugin/Deriver/Types/EntityBundleDeriver.php
EntityTypeDeriver.php in modules/graphql_core/src/Plugin/Deriver/Interfaces/EntityTypeDeriver.php
EntityTypeDeriver.php in modules/graphql_core/src/Plugin/Deriver/Types/EntityTypeDeriver.php

File

modules/graphql_core/src/Plugin/Deriver/EntityTypeDeriverBase.php, line 12

Namespace

Drupal\graphql_core\Plugin\Deriver
View source
abstract class EntityTypeDeriverBase extends DeriverBase implements ContainerDeriverInterface {

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Bundle info manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface
   */
  protected $entityTypeBundleInfo;

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $basePluginId) {
    return new static($container
      ->get('entity_type.manager'), $container
      ->get('entity_type.bundle.info'));
  }

  /**
   * EntityTypeDeriver constructor.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
   *   Instance of an entity type manager.
   * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entityTypeBundleInfo
   *   Instance of the entity bundle info service.
   */
  public function __construct(EntityTypeManagerInterface $entityTypeManager, EntityTypeBundleInfoInterface $entityTypeBundleInfo) {
    $this->entityTypeManager = $entityTypeManager;
    $this->entityTypeBundleInfo = $entityTypeBundleInfo;
  }

  /**
   * Retrieve the interfaces that the entity type should implement.
   *
   * @param \Drupal\Core\Entity\EntityTypeInterface $type
   *   The entity type to retrieve the interfaces for.
   * @param array $basePluginDefinition
   *   The base plugin definition array.
   *
   * @return array
   *   The interfaces that this entity type should implement.
   */
  protected function getInterfaces(EntityTypeInterface $type, array $basePluginDefinition) {
    $pairs = [
      '\\Drupal\\Core\\Entity\\EntityDescriptionInterface' => 'EntityDescribable',
      '\\Drupal\\Core\\Entity\\EntityPublishedInterface' => 'EntityPublishable',
      '\\Drupal\\user\\EntityOwnerInterface' => 'EntityOwnable',
    ];
    $interfaces = isset($basePluginDefinition['interfaces']) ? $basePluginDefinition['interfaces'] : [];
    $interfaces[] = 'Entity';
    foreach ($pairs as $dependency => $interface) {
      if ($type
        ->entityClassImplements($dependency)) {
        $interfaces[] = $interface;
      }
    }
    if ($type
      ->isRevisionable()) {
      $interfaces[] = 'EntityRevisionable';
    }
    return array_unique($interfaces);
  }

}

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
DeriverBase::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverInterface::getDerivativeDefinitions 39
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.