function TypedDataManager::createInstance
Same name in other branches
- 9 core/lib/Drupal/Core/TypedData/TypedDataManager.php \Drupal\Core\TypedData\TypedDataManager::createInstance()
- 10 core/lib/Drupal/Core/TypedData/TypedDataManager.php \Drupal\Core\TypedData\TypedDataManager::createInstance()
- 11.x core/lib/Drupal/Core/TypedData/TypedDataManager.php \Drupal\Core\TypedData\TypedDataManager::createInstance()
Overrides PluginManagerBase::createInstance
1 call to TypedDataManager::createInstance()
- TypedDataManager::create in core/
lib/ Drupal/ Core/ TypedData/ TypedDataManager.php - Creates a new typed data object instance.
File
-
core/
lib/ Drupal/ Core/ TypedData/ TypedDataManager.php, line 76
Class
- TypedDataManager
- Manages data type plugins.
Namespace
Drupal\Core\TypedDataCode
public function createInstance($data_type, array $configuration = []) {
$data_definition = $configuration['data_definition'];
$type_definition = $this->getDefinition($data_type);
if (!isset($type_definition)) {
throw new \InvalidArgumentException("Invalid data type '{$data_type}' has been given");
}
// Allow per-data definition overrides of the used classes, i.e. take over
// classes specified in the type definition.
$class = $data_definition->getClass();
if (!isset($class)) {
throw new PluginException(sprintf('The plugin (%s) did not specify an instance class.', $data_type));
}
$typed_data = $class::createInstance($data_definition, $configuration['name'], $configuration['parent']);
$typed_data->setTypedDataManager($this);
return $typed_data;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.