function TypedDataManager::create

Same name in other branches
  1. 9 core/lib/Drupal/Core/TypedData/TypedDataManager.php \Drupal\Core\TypedData\TypedDataManager::create()
  2. 10 core/lib/Drupal/Core/TypedData/TypedDataManager.php \Drupal\Core\TypedData\TypedDataManager::create()
  3. 11.x core/lib/Drupal/Core/TypedData/TypedDataManager.php \Drupal\Core\TypedData\TypedDataManager::create()

Overrides TypedDataManagerInterface::create

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\TypedData

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.