You are here

public function ContentEntityBase::hasField in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::hasField()

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

5 calls to ContentEntityBase::hasField()
ContentEntityBase::isRevisionTranslationAffected in core/lib/Drupal/Core/Entity/ContentEntityBase.php
Checks whether the current translation is affected by the current revision.
ContentEntityBase::setDefaultLangcode in core/lib/Drupal/Core/Entity/ContentEntityBase.php
Populates the local cache for the default language code.
ContentEntityBase::setRevisionTranslationAffected in core/lib/Drupal/Core/Entity/ContentEntityBase.php
Marks the current revision translation as affected.
ContentEntityBase::__isset in core/lib/Drupal/Core/Entity/ContentEntityBase.php
Implements the magic method for isset().
ContentEntityBase::__unset in core/lib/Drupal/Core/Entity/ContentEntityBase.php
Implements the magic method for unset().

File

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

Class

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

Namespace

Drupal\Core\Entity

Code

public function hasField($field_name) {
  return (bool) $this
    ->getFieldDefinition($field_name);
}