/Drupal 8

public function TypedDataManagerInterface::getPropertyInstance

public TypedDataManagerInterface::getPropertyInstance(TypedDataInterface $object, $property_name, $value = NULL)

Get a typed data instance for a property of a given typed data object.

This method will use prototyping for fast and efficient instantiation of many property objects with the same property path; for example, when multiple comments are used comment_body.0.value needs to be instantiated very often.

Prototyping is done by the root object's data type and the given property path, i.e. all property instances having the same property path and inheriting from the same data type are prototyped.


\Drupal\Core\TypedData\TypedDataInterface $object: The parent typed data object, implementing the TypedDataInterface and either the ListInterface or the ComplexDataInterface.

string $property_name: The name of the property to instantiate, or the delta of an list item.

mixed $value: (optional) The data value. If set, it has to match one of the supported data type formats as documented by the data type classes.

Return value

\Drupal\Core\TypedData\TypedDataInterface The new property instance.


\InvalidArgumentException If the given property is not known, or the passed object does not implement the ListInterface or the ComplexDataInterface.

See also



core/lib/Drupal/Core/TypedData/TypedDataManagerInterface.php, line 163


Defines an interface for typed data manager.




public function getPropertyInstance(TypedDataInterface $object, $property_name, $value = NULL);

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.