File tree Expand file tree Collapse file tree
src/Plugin/GraphQL/DataProducer/EntityDefinition Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,21 +126,21 @@ public function resolve(
126126 if ($ bundle_context ) {
127127 $ key = $ bundle_context ['key ' ];
128128 $ id = $ entity_definition ->id ();
129- $ entity_id = $ id . '. ' . $ id . '. ' . $ key ;
130129 $ fields = $ this ->entityFieldManager ->getFieldDefinitions ($ id , $ key );
130+
131+ // Set entity form default display as context.
132+ $ entity_id = $ id . '. ' . $ key . '.default ' ;
133+ /** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $form_display_context */
134+ $ form_display_context = $ this ->entityTypeManager
135+ ->getStorage ('entity_form_display ' )
136+ ->load ($ entity_id );
137+ $ field_context ->setContextValue ('entity_form_display ' , $ form_display_context );
131138 }
132139 else {
133140 $ id = $ entity_definition ->id ();
134- $ entity_id = $ id . '. ' . $ id . '.default ' ;
135141 $ fields = $ this ->entityFieldManager ->getFieldDefinitions ($ id , $ id );
136142 }
137143
138- /** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $form_display_context */
139- $ form_display_context = $ this ->entityTypeManager
140- ->getStorage ('entity_form_display ' )
141- ->load ($ entity_id );
142-
143- $ field_context ->setContextValue ('entity_form_display ' , $ form_display_context );
144144 if ($ field_types_context ) {
145145 $ field_types = $ field_types_context ['key ' ];
146146 foreach ($ fields as $ field ) {
Original file line number Diff line number Diff line change 22
33namespace Drupal \graphql \Plugin \GraphQL \DataProducer \EntityDefinition \Fields ;
44
5+ use Drupal \Core \Entity \Entity \EntityFormDisplay ;
56use Drupal \Core \Field \FieldDefinitionInterface ;
67use Drupal \graphql \Plugin \GraphQL \DataProducer \DataProducerPluginBase ;
78
@@ -33,19 +34,18 @@ class Hidden extends DataProducerPluginBase {
3334 *
3435 * @param \Drupal\Core\Field\FieldDefinitionInterface $entity_definition_field
3536 * The entity field definition.
36- * @param array |null $entity_form_display_context
37+ * @param \Drupal\Core\Entity\Entity\EntityFormDisplay |null $entity_form_display_context
3738 * Entity form display context.
3839 *
3940 * @return bool
4041 * If the field is hidden or not.
4142 */
4243 public function resolve (
4344 FieldDefinitionInterface $ entity_definition_field ,
44- ?array $ entity_form_display_context = NULL
45+ ?EntityFormDisplay $ entity_form_display_context
4546 ): bool {
4647 if ($ entity_form_display_context ) {
47- $ entity_form_display = $ entity_form_display_context ['key ' ];
48- $ hidden = $ entity_form_display ->get ('hidden ' );
48+ $ hidden = $ entity_form_display_context ->get ('hidden ' );
4949 $ field_id = $ entity_definition_field ->getName ();
5050
5151 if (isset ($ hidden [$ field_id ])) {
Original file line number Diff line number Diff line change 22
33namespace Drupal \graphql \Plugin \GraphQL \DataProducer \EntityDefinition \Fields ;
44
5+ use Drupal \Core \Entity \Entity \EntityFormDisplay ;
56use Drupal \Core \Field \FieldDefinitionInterface ;
67use Drupal \graphql \Plugin \GraphQL \DataProducer \DataProducerPluginBase ;
78
@@ -33,21 +34,20 @@ class Settings extends DataProducerPluginBase {
3334 *
3435 * @param \Drupal\Core\Field\FieldDefinitionInterface $entity_definition_field
3536 * The entity field definition.
36- * @param array |null $entity_form_display_context
37+ * @param \Drupal\Core\Entity\Entity\EntityFormDisplay |null $entity_form_display_context
3738 * Entity form display context.
3839 *
3940 * @return \Iterator
4041 * Field settings.
4142 */
4243 public function resolve (
4344 FieldDefinitionInterface $ entity_definition_field ,
44- ?array $ entity_form_display_context = NULL
45+ ?EntityFormDisplay $ entity_form_display_context
4546 ): \Iterator {
4647 $ settings = $ entity_definition_field ->getSettings ();
4748
4849 if ($ entity_form_display_context ) {
49- $ entity_form_display = $ entity_form_display_context ['key ' ];
50- $ content = $ entity_form_display ->get ('content ' );
50+ $ content = $ entity_form_display_context ->get ('content ' );
5151 $ field_id = $ entity_definition_field ->getName ();
5252 if (isset ($ content [$ field_id ])) {
5353 $ form_settings = $ content [$ field_id ]['settings ' ];
Original file line number Diff line number Diff line change 22
33namespace Drupal \graphql \Plugin \GraphQL \DataProducer \EntityDefinition \Fields ;
44
5+ use Drupal \Core \Entity \Entity \EntityFormDisplay ;
56use Drupal \Core \Field \FieldDefinitionInterface ;
67use Drupal \graphql \Plugin \GraphQL \DataProducer \DataProducerPluginBase ;
78
@@ -33,19 +34,18 @@ class Weight extends DataProducerPluginBase {
3334 *
3435 * @param \Drupal\Core\Field\FieldDefinitionInterface $entity_definition_field
3536 * The entity field definition.
36- * @param array |null $entity_form_display_context
37+ * @param \Drupal\Core\Entity\Entity\EntityFormDisplay |null $entity_form_display_context
3738 * Entity form display context.
3839 *
3940 * @return int
4041 * The field weight.
4142 */
4243 public function resolve (
4344 FieldDefinitionInterface $ entity_definition_field ,
44- ?array $ entity_form_display_context = NULL
45+ ?EntityFormDisplay $ entity_form_display_context
4546 ): int {
4647 if ($ entity_form_display_context ) {
47- $ entity_form_display = $ entity_form_display_context ['key ' ];
48- $ content = $ entity_form_display ->get ('content ' );
48+ $ content = $ entity_form_display_context ->get ('content ' );
4949 $ field_id = $ entity_definition_field ->getName ();
5050
5151 if (isset ($ content [$ field_id ])) {
You can’t perform that action at this time.
0 commit comments