setFieldStorageDefinition example


  protected function initializeFieldUsingFactory($factory_name) {
    switch ($factory_name) {
      case 'createFromFieldStorageDefinition':
        return FieldDefinition::createFromFieldStorageDefinition($this->storageDefinition);

      case 'create':
        $definition = FieldDefinition::create($this->fieldType);
        $definition->setFieldStorageDefinition($this->storageDefinition);
        return $definition;

      case 'createFromDataType':
        $definition = FieldDefinition::createFromDataType($this->fieldType);
        $definition->setFieldStorageDefinition($this->storageDefinition);
        return $definition;

      case 'createFromItemType':
        $definition = FieldDefinition::createFromItemType($this->fieldType);
        $definition->setFieldStorageDefinition($this->storageDefinition);
        return $definition;
    }
/** * Creates a new field definition. * * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storageDefinition * The associated field storage definition. * * @return static */
  public static function createFromFieldStorageDefinition(FieldStorageDefinitionInterface $storageDefinition) {
    $field_definition = new static();
    $field_definition->setFieldStorageDefinition($storageDefinition);
    return $field_definition;
  }

  /** * {@inheritdoc} */
  public function getName() {
    return $this->getFieldStorageDefinition()->getName();
  }

  /** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.