You are here

public function ConfigEntityAdapter::get in Drupal 8

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

Gets a property object.

Parameters

$property_name: The name of the property to get; e.g., 'title' or 'name'.

Return value

\Drupal\Core\TypedData\TypedDataInterface The property object.

Throws

\InvalidArgumentException If an invalid property name is given.

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

Overrides EntityAdapter::get

File

core/lib/Drupal/Core/Entity/Plugin/DataType/ConfigEntityAdapter.php, line 31

Class

ConfigEntityAdapter
Enhances EntityAdapter for config entities.

Namespace

Drupal\Core\Entity\Plugin\DataType

Code

public function get($property_name) {
  if (!isset($this->entity)) {
    throw new MissingDataException("Unable to get property {$property_name} as no entity has been provided.");
  }
  return $this
    ->getConfigTypedData()
    ->get($property_name);
}