function entity_test_entity_type_alter in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_type_alter()
Implements hook_entity_type_alter().
File
- core/
modules/ system/ tests/ modules/ entity_test/ entity_test.module, line 80 - Test module for the entity API providing several entity types for testing.
Code
function entity_test_entity_type_alter(array &$entity_types) {
$state = \Drupal::state();
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
foreach (entity_test_entity_types() as $entity_type) {
// Optionally specify a translation handler for testing translations.
if ($state
->get('entity_test.translation')) {
$translation = $entity_types[$entity_type]
->get('translation');
$translation[$entity_type] = TRUE;
$entity_types[$entity_type]
->set('translation', $translation);
}
}
// Allow entity_test_update tests to override the entity type definition.
$entity_types['entity_test_update'] = $state
->get('entity_test_update.entity_type', $entity_types['entity_test_update']);
// Enable the entity_test_new only when needed.
if (!$state
->get('entity_test_new')) {
unset($entity_types['entity_test_new']);
}
}