function EntityDefinitionTestTrait::getUpdatedFieldStorageDefinitions
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Entity/Traits/EntityDefinitionTestTrait.php \Drupal\Tests\system\Functional\Entity\Traits\EntityDefinitionTestTrait::getUpdatedFieldStorageDefinitions()
- 8.9.x core/modules/system/tests/src/Functional/Entity/Traits/EntityDefinitionTestTrait.php \Drupal\Tests\system\Functional\Entity\Traits\EntityDefinitionTestTrait::getUpdatedFieldStorageDefinitions()
- 10 core/modules/system/tests/src/Functional/Entity/Traits/EntityDefinitionTestTrait.php \Drupal\Tests\system\Functional\Entity\Traits\EntityDefinitionTestTrait::getUpdatedFieldStorageDefinitions()
Returns the required rev / mul field definitions for an entity type.
Parameters
bool $revisionable: (optional) Whether the entity type should be revisionable or not. Defaults to FALSE.
bool $translatable: (optional) Whether the entity type should be translatable or not. Defaults to FALSE.
Return value
\Drupal\Core\Field\FieldStorageDefinitionInterface[] An array of field storage definition objects.
9 calls to EntityDefinitionTestTrait::getUpdatedFieldStorageDefinitions()
- EntityDefinitionTestTrait::resetEntityType in core/
modules/ system/ tests/ src/ Functional/ Entity/ Traits/ EntityDefinitionTestTrait.php - Resets the entity type definition.
- EntityDefinitionTestTrait::updateEntityTypeToNotRevisionable in core/
modules/ system/ tests/ src/ Functional/ Entity/ Traits/ EntityDefinitionTestTrait.php - Updates the 'entity_test_update' entity type not revisionable.
- EntityDefinitionTestTrait::updateEntityTypeToNotTranslatable in core/
modules/ system/ tests/ src/ Functional/ Entity/ Traits/ EntityDefinitionTestTrait.php - Updates the 'entity_test_update' entity type to not translatable.
- EntityDefinitionTestTrait::updateEntityTypeToRevisionable in core/
modules/ system/ tests/ src/ Functional/ Entity/ Traits/ EntityDefinitionTestTrait.php - Updates the 'entity_test_update' entity type to revisionable.
- EntityDefinitionTestTrait::updateEntityTypeToRevisionableAndTranslatable in core/
modules/ system/ tests/ src/ Functional/ Entity/ Traits/ EntityDefinitionTestTrait.php - Updates the test entity type to be revisionable and translatable.
File
-
core/
modules/ system/ tests/ src/ Functional/ Entity/ Traits/ EntityDefinitionTestTrait.php, line 494
Class
- EntityDefinitionTestTrait
- Provides some test methods used to update existing entity definitions.
Namespace
Drupal\Tests\system\Functional\Entity\TraitsCode
protected function getUpdatedFieldStorageDefinitions($revisionable = FALSE, $translatable = FALSE) {
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $field_storage_definitions */
$field_storage_definitions = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions('entity_test_update');
if ($revisionable) {
// The 'langcode' is already available for the 'entity_test_update' entity
// type because it has the 'langcode' entity key defined.
$field_storage_definitions['langcode']->setRevisionable(TRUE);
$field_storage_definitions['revision_id'] = BaseFieldDefinition::create('integer')->setName('revision_id')
->setTargetEntityTypeId('entity_test_update')
->setTargetBundle(NULL)
->setLabel(new TranslatableMarkup('Revision ID'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
$field_storage_definitions['revision_default'] = BaseFieldDefinition::create('boolean')->setName('revision_default')
->setTargetEntityTypeId('entity_test_update')
->setTargetBundle(NULL)
->setLabel(new TranslatableMarkup('Default revision'))
->setDescription(new TranslatableMarkup('A flag indicating whether this was a default revision when it was saved.'))
->setStorageRequired(TRUE)
->setInternal(TRUE)
->setTranslatable(FALSE)
->setRevisionable(TRUE);
}
if ($translatable) {
// The 'langcode' is already available for the 'entity_test_update' entity
// type because it has the 'langcode' entity key defined.
$field_storage_definitions['langcode']->setTranslatable(TRUE);
$field_storage_definitions['default_langcode'] = BaseFieldDefinition::create('boolean')->setName('default_langcode')
->setTargetEntityTypeId('entity_test_update')
->setTargetBundle(NULL)
->setLabel(new TranslatableMarkup('Default translation'))
->setDescription(new TranslatableMarkup('A flag indicating whether this is the default translation.'))
->setTranslatable(TRUE)
->setRevisionable(TRUE)
->setDefaultValue(TRUE);
}
if ($revisionable && $translatable) {
$field_storage_definitions['revision_translation_affected'] = BaseFieldDefinition::create('boolean')->setName('revision_translation_affected')
->setTargetEntityTypeId('entity_test_update')
->setTargetBundle(NULL)
->setLabel(new TranslatableMarkup('Revision translation affected'))
->setDescription(new TranslatableMarkup('Indicates if the last edit of a translation belongs to current revision.'))
->setReadOnly(TRUE)
->setRevisionable(TRUE)
->setTranslatable(TRUE);
}
return $field_storage_definitions;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.