You are here

public function ContentEntityBase::getFields in Drupal 8

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

Gets an array of all field item lists.

Parameters

bool $include_computed: If set to TRUE, computed fields are included. Defaults to TRUE.

Return value

\Drupal\Core\Field\FieldItemListInterface[] An array of field item lists implementing, keyed by field name.

Overrides FieldableEntityInterface::getFields

3 calls to ContentEntityBase::getFields()
ContentEntityBase::getIterator in core/lib/Drupal/Core/Entity/ContentEntityBase.php
ContentEntityBase::referencedEntities in core/lib/Drupal/Core/Entity/ContentEntityBase.php
Gets a list of entities referenced by this entity.
ContentEntityBase::toArray in core/lib/Drupal/Core/Entity/ContentEntityBase.php
Gets an array of all property values.

File

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

Class

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

Namespace

Drupal\Core\Entity

Code

public function getFields($include_computed = TRUE) {
  $fields = [];
  foreach ($this
    ->getFieldDefinitions() as $name => $definition) {
    if ($include_computed || !$definition
      ->isComputed()) {
      $fields[$name] = $this
        ->get($name);
    }
  }
  return $fields;
}