File tree Expand file tree Collapse file tree
modules/graphql_core/src/Plugin/GraphQL/Fields/Entity Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Drupal \graphql_core \Plugin \GraphQL \Fields \Entity ;
4+
5+ use Drupal \Core \Entity \ContentEntityInterface ;
6+ use Drupal \graphql \Plugin \GraphQL \Fields \FieldPluginBase ;
7+ use Youshido \GraphQL \Execution \ResolveInfo ;
8+
9+ /**
10+ * @GraphQLField(
11+ * id = "entity_translations",
12+ * name = "entityTranslations",
13+ * secure = true,
14+ * type = "[Entity]",
15+ * parents = {"Entity"}
16+ * )
17+ */
18+ class EntityTranslations extends FieldPluginBase {
19+
20+ /**
21+ * {@inheritdoc}
22+ */
23+ public function resolveValues ($ value , array $ args , ResolveInfo $ info ) {
24+ if ($ value instanceof ContentEntityInterface) {
25+ $ languages = $ value ->getTranslationLanguages ();
26+ foreach ($ languages as $ language ) {
27+ yield $ value ->getTranslation ($ language ->getId ());
28+ }
29+ }
30+ }
31+
32+ }
You can’t perform that action at this time.
0 commit comments