You are here

class ConfigEntityTypeResolver in GraphQL 8

Same name and namespace in other branches
  1. 8.2 src/TypeResolver/ConfigEntityTypeResolver.php \Drupal\graphql\TypeResolver\ConfigEntityTypeResolver

Resolves the schema for config entities.

Hierarchy

Expanded class hierarchy of ConfigEntityTypeResolver

1 string reference to 'ConfigEntityTypeResolver'
graphql.services.yml in ./graphql.services.yml
graphql.services.yml
1 service uses ConfigEntityTypeResolver
graphql.type_resolver.typed_data.config_entity in ./graphql.services.yml
Drupal\graphql\TypeResolver\ConfigEntityTypeResolver

File

src/TypeResolver/ConfigEntityTypeResolver.php, line 13

Namespace

Drupal\graphql\TypeResolver
View source
class ConfigEntityTypeResolver implements TypeResolverInterface {

  /**
   * The entity manager service.
   *
   * @var \Drupal\Core\Entity\EntityManagerInterface
   */
  protected $entityManager;

  /**
   * Constructs a ConfigEntityTypeResolver object.
   *
   * @param \Drupal\Core\Entity\EntityManagerInterface $entityManager
   *   The entity manager service.
   */
  public function __construct(EntityManagerInterface $entityManager) {
    $this->entityManager = $entityManager;
  }

  /**
   * {@inheritdoc}
   */
  public function applies($type) {
    if ($type instanceof EntityDataDefinitionInterface) {
      $entityTypeId = $type
        ->getEntityTypeId();
      $entityType = $this->entityManager
        ->getDefinition($entityTypeId);
      return $entityType
        ->isSubclassOf('\\Drupal\\Core\\Config\\Entity\\ConfigEntityInterface');
    }
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function resolveRecursive($type) {

    // @todo We do not currently support config entities.
    return NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigEntityTypeResolver::$entityManager protected property The entity manager service.
ConfigEntityTypeResolver::applies public function Overrides TypeResolverInterface::applies
ConfigEntityTypeResolver::resolveRecursive public function Overrides TypeResolverInterface::resolveRecursive
ConfigEntityTypeResolver::__construct public function Constructs a ConfigEntityTypeResolver object.