You are here

public function Map::get in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php \Drupal\Core\TypedData\Plugin\DataType\Map::get()
  2. 10 core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php \Drupal\Core\TypedData\Plugin\DataType\Map::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 ComplexDataInterface::get

2 calls to Map::get()
EntityReferenceItem::onChange in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
React to changes to a child property or item.
Map::getProperties in core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php
Gets an array of property objects.

File

core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php, line 113

Class

Map
The "map" data type.

Namespace

Drupal\Core\TypedData\Plugin\DataType

Code

public function get($property_name) {
  if (!isset($this->properties[$property_name])) {
    $value = NULL;
    if (isset($this->values[$property_name])) {
      $value = $this->values[$property_name];
    }

    // If the property is unknown, this will throw an exception.
    $this->properties[$property_name] = $this
      ->getTypedDataManager()
      ->getPropertyInstance($this, $property_name, $value);
  }
  return $this->properties[$property_name];
}