public static function DataDynamicReferenceDefinition::create in Dynamic Entity Reference 8.2
Same name and namespace in other branches
- 8 src/DataDynamicReferenceDefinition.php \Drupal\dynamic_entity_reference\DataDynamicReferenceDefinition::create()
Creates a new data reference definition.
Parameters
string $target_data_type: The data type of the referenced data.
Return value
$this
Overrides DataReferenceDefinition::create
File
- src/
DataDynamicReferenceDefinition.php, line 27
Class
- DataDynamicReferenceDefinition
- A typed data definition class for defining dynamic references.
Namespace
Drupal\dynamic_entity_referenceCode
public static function create($target_data_type) {
$definition['type'] = 'dynamic_' . $target_data_type . '_reference';
/** @var \Drupal\Core\TypedData\DataReferenceDefinition $definition */
$definition = new static($definition);
return $definition
->setTargetDefinition(\Drupal::typedDataManager()
->createDataDefinition($target_data_type));
}