You are here

public function ContentEntityBase::getFieldDefinition in Drupal 10

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

Gets the definition of a contained field.

Parameters

string $name: The name of the field.

Return value

\Drupal\Core\Field\FieldDefinitionInterface|null The definition of the field or null if the field does not exist.

Overrides FieldableEntityInterface::getFieldDefinition

4 calls to ContentEntityBase::getFieldDefinition()
ContentEntityBase::getEntityKey in core/lib/Drupal/Core/Entity/ContentEntityBase.php
Gets the value of the given entity key, if defined.
ContentEntityBase::getTranslatedField in core/lib/Drupal/Core/Entity/ContentEntityBase.php
Gets a translated field.
ContentEntityBase::hasField in core/lib/Drupal/Core/Entity/ContentEntityBase.php
Determines whether the entity has a field with the given name.
ContentEntityBase::__construct in core/lib/Drupal/Core/Entity/ContentEntityBase.php
Constructs an Entity object.

File

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

Class

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

Namespace

Drupal\Core\Entity

Code

public function getFieldDefinition($name) {
  if (!isset($this->fieldDefinitions)) {
    $this
      ->getFieldDefinitions();
  }
  if (isset($this->fieldDefinitions[$name])) {
    return $this->fieldDefinitions[$name];
  }
}