ContentEntityBase::hasField

public ContentEntityBase::hasField($field_name)

Determines whether the entity has a field with the given name.

Parameters

string $field_name: The field name.

Return value

bool TRUE if the entity has a field with the given name. FALSE otherwise.

Overrides FieldableEntityInterface::hasField

File

core/lib/Drupal/Core/Entity/ContentEntityBase.php, line 443

Class

ContentEntityBase
Implements Entity Field API specific enhancements to the Entity class.

Namespace

Drupal\Core\Entity

Code

1
2
3
public function hasField($field_name) {
  return (bool) $this->getFieldDefinition($field_name);
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.