function FieldDefinitionTest::initializeFieldUsingFactory
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php \Drupal\Tests\Core\Entity\FieldDefinitionTest::initializeFieldUsingFactory()
Creates a bundle field using a specified factory.
Parameters
string $factory_name: The factory name to use.
Return value
\Drupal\Core\Field\FieldDefinition
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ FieldDefinitionTest.php, line 368
Class
- FieldDefinitionTest
- Unit test for the FieldDefinition class.
Namespace
Drupal\Tests\Core\EntityCode
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;
}
throw new \InvalidArgumentException("Invalid factory name '{$factory_name}' passed to " . __METHOD__);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.