public TypedDataManager::createDataDefinition($data_type)
Creates a new data definition object.
While data definitions objects may be created directly if the definition class used by a data type is known, this method allows the creation of data definitions for any given data type.
For example, if a definition for a map is to be created, the following code could be used instead of calling this method with the argument 'map':
$map_definition = \Drupal\Core\TypedData\MapDataDefinition::create();
string $data_type: The data type plugin ID, for which a data definition object should be created.
\Drupal\Core\TypedData\DataDefinitionInterface A data definition object for the given data type. The class of this object is provided by the definition_class in the plugin annotation.
Overrides TypedDataManagerInterface::createDataDefinition
\Drupal\Core\TypedData\TypedDataManager::createListDataDefinition()
public function createDataDefinition($data_type) { $type_definition = $this->getDefinition($data_type); if (!isset($type_definition)) { throw new \InvalidArgumentException("Invalid data type '$data_type' has been given"); } $class = $type_definition['definition_class']; return $class::createFromDataType($data_type); }
© 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.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!TypedData!TypedDataManager.php/function/TypedDataManager::createDataDefinition/8.1.x