public function Weight::resolve in GraphQL 8.4
Resolves the "weight" property.
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
int The field weight.
File
- src/
Plugin/ GraphQL/ DataProducer/ EntityDefinition/ Fields/ Weight.php, line 43
Class
- Weight
- Retrieves the weight value of a field.
Namespace
Drupal\graphql\Plugin\GraphQL\DataProducer\EntityDefinition\FieldsCode
public function resolve(FieldDefinitionInterface $entity_definition_field, ?EntityFormDisplay $entity_form_display_context) : int {
if ($entity_form_display_context) {
$content = $entity_form_display_context
->get('content');
$field_id = $entity_definition_field
->getName();
if (isset($content[$field_id])) {
return $content[$field_id]['weight'];
}
else {
return 0;
}
}
else {
return 0;
}
}