function EntityDefinitionTestTrait::getUpdatedEntityTypeDefinition
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Entity/Traits/EntityDefinitionTestTrait.php \Drupal\Tests\system\Functional\Entity\Traits\EntityDefinitionTestTrait::getUpdatedEntityTypeDefinition()
- 8.9.x core/modules/system/tests/src/Functional/Entity/Traits/EntityDefinitionTestTrait.php \Drupal\Tests\system\Functional\Entity\Traits\EntityDefinitionTestTrait::getUpdatedEntityTypeDefinition()
- 11.x core/modules/system/tests/src/Functional/Entity/Traits/EntityDefinitionTestTrait.php \Drupal\Tests\system\Functional\Entity\Traits\EntityDefinitionTestTrait::getUpdatedEntityTypeDefinition()
Returns an entity type definition, possibly updated to be rev or mul.
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\Entity\EntityTypeInterface An entity type definition.
10 calls to EntityDefinitionTestTrait::getUpdatedEntityTypeDefinition()
- 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 440
Class
- EntityDefinitionTestTrait
- Provides some test methods used to update existing entity definitions.
Namespace
Drupal\Tests\system\Functional\Entity\TraitsCode
protected function getUpdatedEntityTypeDefinition($revisionable = FALSE, $translatable = FALSE) {
$entity_type = clone \Drupal::entityTypeManager()->getDefinition('entity_test_update');
if ($revisionable) {
$keys = $entity_type->getKeys();
$keys['revision'] = 'revision_id';
$entity_type->set('entity_keys', $keys);
$entity_type->set('revision_table', 'entity_test_update_revision');
}
else {
$keys = $entity_type->getKeys();
$keys['revision'] = '';
$entity_type->set('entity_keys', $keys);
$entity_type->set('revision_table', NULL);
}
if ($translatable) {
$entity_type->set('translatable', TRUE);
$entity_type->set('data_table', 'entity_test_update_data');
}
else {
$entity_type->set('translatable', FALSE);
$entity_type->set('data_table', NULL);
}
if ($revisionable && $translatable) {
$entity_type->set('revision_data_table', 'entity_test_update_revision_data');
}
else {
$entity_type->set('revision_data_table', NULL);
}
$this->state
->set('entity_test_update.entity_type', $entity_type);
$this->container
->get('entity_type.manager')
->clearCachedDefinitions();
$this->container
->get('entity_type.bundle.info')
->clearCachedBundles();
$this->container
->get('entity_field.manager')
->clearCachedFieldDefinitions();
return $entity_type;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.