public static BaseFieldDefinition::createFromFieldStorageDefinition(FieldStorageDefinitionInterface $definition)
Creates a new field definition based upon a field storage definition.
In cases where one needs a field storage definitions to act like full field definitions, this creates a new field definition based upon the (limited) information available. That way it is possible to use the field definition in places where a full field definition is required; e.g., with widgets or formatters.
\Drupal\Core\Field\FieldStorageDefinitionInterface $definition: The field storage definition to base the new field definition upon.
$this
public static function createFromFieldStorageDefinition(FieldStorageDefinitionInterface $definition) { return static::create($definition->getType()) ->setCardinality($definition->getCardinality()) ->setConstraints($definition->getConstraints()) ->setCustomStorage($definition->hasCustomStorage()) ->setDescription($definition->getDescription()) ->setLabel($definition->getLabel()) ->setName($definition->getName()) ->setProvider($definition->getProvider()) ->setQueryable($definition->isQueryable()) ->setRevisionable($definition->isRevisionable()) ->setSettings($definition->getSettings()) ->setTargetEntityTypeId($definition->getTargetEntityTypeId()) ->setTranslatable($definition->isTranslatable()); }
© 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!Field!BaseFieldDefinition.php/function/BaseFieldDefinition::createFromFieldStorageDefinition/8.1.x