public function TypedDataManager::create in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/TypedData/TypedDataManager.php \Drupal\Core\TypedData\TypedDataManager::create()
Creates a new typed data object instance.
Parameters
\Drupal\Core\TypedData\DataDefinitionInterface $definition: The data definition of the typed data object. For backwards-compatibility an array representation of the data definition may be passed also.
mixed $value: (optional) The data value. If set, it has to match one of the supported data type format as documented for the data type classes.
string $name: (optional) If a property or list item is to be created, the name of the property or the delta of the list item.
mixed $parent: (optional) If a property or list item is to be created, the parent typed data object implementing either the ListInterface or the ComplexDataInterface.
Return value
\Drupal\Core\TypedData\TypedDataInterface The instantiated typed data object.
Overrides TypedDataManagerInterface::create
See also
\Drupal\Core\TypedData\TypedDataManager::getPropertyInstance()
\Drupal\Core\TypedData\Plugin\DataType\BinaryData
\Drupal\Core\TypedData\Plugin\DataType\BooleanData
\Drupal\Core\TypedData\Plugin\DataType\Date
\Drupal\Core\TypedData\Plugin\DataType\Duration
\Drupal\Core\TypedData\Plugin\DataType\FloatData
\Drupal\Core\TypedData\Plugin\DataType\IntegerData
\Drupal\Core\TypedData\Plugin\DataType\StringData
\Drupal\Core\TypedData\Plugin\DataType\Uri
2 calls to TypedDataManager::create()
- TypedConfigManager::createFromNameAndData in core/
lib/ Drupal/ Core/ Config/ TypedConfigManager.php - Gets typed data for a given configuration name and its values.
- TypedDataManager::getPropertyInstance in core/
lib/ Drupal/ Core/ TypedData/ TypedDataManager.php - Get a typed data instance for a property of a given typed data object.
File
- core/
lib/ Drupal/ Core/ TypedData/ TypedDataManager.php, line 99
Class
- TypedDataManager
- Manages data type plugins.
Namespace
Drupal\Core\TypedDataCode
public function create(DataDefinitionInterface $definition, $value = NULL, $name = NULL, $parent = NULL) {
$typed_data = $this
->createInstance($definition
->getDataType(), [
'data_definition' => $definition,
'name' => $name,
'parent' => $parent,
]);
if (isset($value)) {
$typed_data
->setValue($value, FALSE);
}
return $typed_data;
}