You are here

public function Settings::resolve in GraphQL 8.4

Resolves the field settings.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $entity_definition_field: The entity field definition.

\Drupal\Core\Entity\Entity\EntityFormDisplay|null $entity_form_display_context: Entity form display context.

Return value

\Iterator Field settings.

File

src/Plugin/GraphQL/DataProducer/EntityDefinition/Fields/Settings.php, line 43

Class

Settings
Retrieves the "settings" from a given field definition.

Namespace

Drupal\graphql\Plugin\GraphQL\DataProducer\EntityDefinition\Fields

Code

public function resolve(FieldDefinitionInterface $entity_definition_field, ?EntityFormDisplay $entity_form_display_context) : \Iterator {
  $settings = $entity_definition_field
    ->getSettings();
  if ($entity_form_display_context) {
    $content = $entity_form_display_context
      ->get('content');
    $field_id = $entity_definition_field
      ->getName();
    if (isset($content[$field_id])) {
      $form_settings = $content[$field_id]['settings'];
      $settings['form_settings'] = $form_settings;
    }
  }
  foreach ($settings as $key => $value) {
    (yield [
      'key' => $key,
      'value' => $value,
    ]);
  }
}