function EntityDataDefinition::createFromDataType

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

Overrides DataDefinition::createFromDataType

File

core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php, line 55

Class

EntityDataDefinition
A typed data definition class for describing entities.

Namespace

Drupal\Core\Entity\TypedData

Code

public static function createFromDataType($data_type) {
    $parts = explode(':', $data_type);
    if ($parts[0] != 'entity') {
        throw new \InvalidArgumentException('Data type must be in the form of "entity:ENTITY_TYPE:BUNDLE."');
    }
    return static::create(isset($parts[1]) ? $parts[1] : NULL, isset($parts[2]) ? $parts[2] : NULL);
}

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