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'))); } /** * {@inheritdoc} */ public function getTargetDefinition() { return $this->targetDefinition; } /** * Sets the definition of the referenced data. * * @param \Drupal\Core\TypedData\DataDefinitionInterface $definition * The target definition to set. * * @return $this */ public function setTargetDefinition(DataDefinitionInterface $definition) { $this->targetDefinition = $definition; return $this; } }