Skip to content

Commit 66d2171

Browse files
authored
fix(example): Update example to use EntityTypeManager (drupal-graphql#1109)
1 parent 7586fce commit 66d2171

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

examples/graphql_example/src/Plugin/GraphQL/DataProducer/QueryArticles.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class QueryArticles extends DataProducerPluginBase implements ContainerFactoryPl
3737
/**
3838
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
3939
*/
40-
protected $entityManager;
40+
protected $entityTypeManager;
4141

4242
/**
4343
* {@inheritdoc}
@@ -49,7 +49,7 @@ public static function create(ContainerInterface $container, array $configuratio
4949
$configuration,
5050
$plugin_id,
5151
$plugin_definition,
52-
$container->get('entity.manager')
52+
$container->get('entity_type.manager')
5353
);
5454
}
5555

@@ -62,18 +62,18 @@ public static function create(ContainerInterface $container, array $configuratio
6262
* The plugin id.
6363
* @param mixed $pluginDefinition
6464
* The plugin definition.
65-
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityManager
65+
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
6666
*
6767
* @codeCoverageIgnore
6868
*/
6969
public function __construct(
7070
array $configuration,
7171
$pluginId,
7272
$pluginDefinition,
73-
EntityTypeManagerInterface $entityManager
73+
EntityTypeManagerInterface $entityTypeManager
7474
) {
7575
parent::__construct($configuration, $pluginId, $pluginDefinition);
76-
$this->entityManager = $entityManager;
76+
$this->entityTypeManager = $entityTypeManager;
7777
}
7878

7979
/**
@@ -90,17 +90,17 @@ public function resolve($offset, $limit, RefinableCacheableDependencyInterface $
9090
throw new UserError(sprintf('Exceeded maximum query limit: %s.', static::MAX_LIMIT));
9191
}
9292

93-
$storage = $this->entityManager->getStorage('node');
94-
$type = $storage->getEntityType();
93+
$storage = $this->entityTypeManager->getStorage('node');
94+
$entityType = $storage->getEntityType();
9595
$query = $storage->getQuery()
9696
->currentRevision()
9797
->accessCheck();
9898

99-
$query->condition($type->getKey('bundle'), 'article');
99+
$query->condition($entityType->getKey('bundle'), 'article');
100100
$query->range($offset, $limit);
101101

102-
$metadata->addCacheTags($type->getListCacheTags());
103-
$metadata->addCacheContexts($type->getListCacheContexts());
102+
$metadata->addCacheTags($entityType->getListCacheTags());
103+
$metadata->addCacheContexts($entityType->getListCacheContexts());
104104

105105
return new QueryConnection($query);
106106
}

0 commit comments

Comments
 (0)