public function ResourceObject::getField in JSON:API 8.2
Gets the given field.
Parameters
string $public_field_name: A public field name.
Return value
mixed|\Drupal\Core\Field\FieldItemListInterface|null The field or NULL if the resource object does not have the given field.
See also
::extractFields()
File
- src/
JsonApiResource/ ResourceObject.php, line 139
Class
- ResourceObject
- Represents a JSON:API resource object.
Namespace
Drupal\jsonapi\JsonApiResourceCode
public function getField($public_field_name) {
return $this
->hasField($public_field_name) ? $this->fields[$public_field_name] : NULL;
}