You are here

public function EntityAdapter::getProperties in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php \Drupal\Core\Entity\Plugin\DataType\EntityAdapter::getProperties()

Gets an array of property objects.

Parameters

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

Return value

\Drupal\Core\TypedData\TypedDataInterface[] An array of property objects implementing the TypedDataInterface, keyed by property name.

Throws

\Drupal\Core\TypedData\Exception\MissingDataException If the complex data structure is unset and no property can be created.

Overrides ComplexDataInterface::getProperties

1 call to EntityAdapter::getProperties()
EntityAdapter::applyDefaultValue in core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php
Applies the default value.
1 method overrides EntityAdapter::getProperties()
ConfigEntityAdapter::getProperties in core/lib/Drupal/Core/Entity/Plugin/DataType/ConfigEntityAdapter.php
Gets an array of property objects.

File

core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php, line 105

Class

EntityAdapter
Defines the "entity" data type.

Namespace

Drupal\Core\Entity\Plugin\DataType

Code

public function getProperties($include_computed = FALSE) {
  if (!isset($this->entity)) {
    throw new MissingDataException('Unable to get properties as no entity has been provided.');
  }
  if (!$this->entity instanceof FieldableEntityInterface) {
    return [];
  }
  return $this->entity
    ->getFields($include_computed);
}