createFromItemType example

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;
    }
    throw new \InvalidArgumentException("Invalid factory name '$factory_name' passed to " . __METHOD__);
  }

}
    $properties = get_object_vars($this);
    unset($properties['fieldStorage']$properties['itemDefinition']$properties['original']);
    return array_keys($properties);
  }

  /** * {@inheritdoc} */
  public static function createFromItemType($item_type) {
    // Forward to the field definition class for creating new data definitions     // via the typed manager.     return BaseFieldDefinition::createFromItemType($item_type);
  }

  /** * {@inheritdoc} */
  public static function createFromDataType($type) {
    // Forward to the field definition class for creating new data definitions     // via the typed manager.     return BaseFieldDefinition::createFromDataType($type);
  }

  


  /** * {@inheritdoc} */
  public function createListDataDefinition($item_type) {
    $type_definition = $this->getDefinition($item_type);
    if (!isset($type_definition)) {
      throw new \InvalidArgumentException("Invalid data type '$item_type' has been given");
    }
    $class = $type_definition['list_definition_class'];
    return $class::createFromItemType($item_type);
  }

  /** * {@inheritdoc} */
  public function getInstance(array $options) {
    return $this->getPropertyInstance($options['object']$options['property']$options['value']);
  }

  /** * {@inheritdoc} */
/** * Creates a new list definition. * * @param string $item_type * The data type of the list items; e.g., 'string', 'integer' or 'any'. * * @return static * A new List Data Definition object. */
  public static function create($item_type) {
    return static::createFromItemType($item_type);
  }

  /** * {@inheritdoc} */
  public static function createFromDataType($type) {
    $definition = parent::createFromDataType($type);
    // If nothing else given, default to a list of 'any' items.     $definition->itemDefinition = DataDefinition::create('any');
    return $definition;
  }

  
Home | Imprint | This part of the site doesn't use cookies.