3
3
namespace Drupal \graphql \Plugin \GraphQL \DataProducer \EntityDefinition ;
4
4
5
5
use Drupal \Core \Entity \ContentEntityType ;
6
+ use Drupal \Core \Entity \EntityFieldManager ;
6
7
use Drupal \Core \Entity \EntityTypeInterface ;
7
8
use Drupal \Core \Entity \EntityTypeManager ;
8
9
use Drupal \Core \Field \BaseFieldDefinition ;
@@ -47,6 +48,13 @@ class Fields extends DataProducerPluginBase implements ContainerFactoryPluginInt
47
48
*/
48
49
protected $ entityTypeManager ;
49
50
51
+ /**
52
+ * The entity field manager service.
53
+ *
54
+ * @var \Drupal\Core\Entity\EntityFieldManager
55
+ */
56
+ protected $ entityFieldManager ;
57
+
50
58
/**
51
59
* {@inheritdoc}
52
60
*
@@ -57,7 +65,8 @@ public static function create(ContainerInterface $container, array $configuratio
57
65
$ configuration ,
58
66
$ plugin_id ,
59
67
$ plugin_definition ,
60
- $ container ->get ('entity_type.manager ' )
68
+ $ container ->get ('entity_type.manager ' ),
69
+ $ container ->get ('entity_field.manager ' )
61
70
);
62
71
}
63
72
@@ -72,17 +81,21 @@ public static function create(ContainerInterface $container, array $configuratio
72
81
* The plugin definition array.
73
82
* @param \Drupal\Core\Entity\EntityTypeManager $entity_type_manager
74
83
* The entity type manager service.
84
+ * @param \Drupal\Core\Entity\EntityFieldManager $entity_field_manager
85
+ * The entity field manager service.
75
86
*
76
87
* @codeCoverageIgnore
77
88
*/
78
89
public function __construct (
79
90
array $ configuration ,
80
91
string $ plugin_id ,
81
92
array $ plugin_definition ,
82
- EntityTypeManager $ entity_type_manager
93
+ EntityTypeManager $ entity_type_manager ,
94
+ EntityFieldManager $ entity_field_manager
83
95
) {
84
96
parent ::__construct ($ configuration , $ plugin_id , $ plugin_definition );
85
97
$ this ->entityTypeManager = $ entity_type_manager ;
98
+ $ this ->entityFieldManager = $ entity_field_manager ;
86
99
}
87
100
88
101
/**
@@ -115,12 +128,12 @@ public function resolve(
115
128
$ key = $ bundle_context ['key ' ];
116
129
$ id = $ entity_definition ->id ();
117
130
$ entity_id = $ id . '. ' . $ id . '. ' . $ key ;
118
- $ fields = \Drupal:: entityManager () ->getFieldDefinitions ($ id , $ key );
131
+ $ fields = $ this -> entityFieldManager ->getFieldDefinitions ($ id , $ key );
119
132
}
120
133
else {
121
134
$ id = $ entity_definition ->id ();
122
135
$ entity_id = $ id . '. ' . $ id . '.default ' ;
123
- $ fields = \Drupal:: entityManager () ->getFieldDefinitions ($ id , $ id );
136
+ $ fields = $ this -> entityFieldManager ->getFieldDefinitions ($ id , $ id );
124
137
}
125
138
126
139
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $form_display_context */
0 commit comments