/**
* Creates a new data reference definition.
*
* @param string $target_data_type
* The data type of the referenced data.
*
* @return static
*/
public static function create($target_data_type) { // This assumes implementations use a "TYPE_reference" naming pattern.
$definition = parent::
create($target_data_type . '_reference'
);
return $definition->
setTargetDefinition(\Drupal::
typedDataManager()->
createDataDefinition($target_data_type));
} /**
* {@inheritdoc}
*/
public static function createFromDataType($data_type) { if (substr($data_type, -
strlen('_reference'
)) != '_reference'
) { throw new \
InvalidArgumentException('Data type must be of the form "{TARGET_TYPE}_reference"'
);
} // Cut of the _reference suffix.
return static::
create(substr($data_type, 0,
strlen($data_type) -
strlen('_reference'
)));
}