public function EventSubscriber::onImportTransform in Drupal 9
Same name and namespace in other branches
- 8 core/modules/config/tests/config_transformer_test/src/EventSubscriber.php \Drupal\config_transformer_test\EventSubscriber::onImportTransform()
The storage is transformed for importing.
In this transformation we ignore the site name from the sync storage and set it always to the currently active site name with an additional string so that there will always be something to import. Do not do this outside of tests.
Parameters
\Drupal\Core\Config\StorageTransformEvent $event: The config storage transform event.
File
- core/
modules/ config/ tests/ config_transformer_test/ src/ EventSubscriber.php, line 67
Class
- EventSubscriber
- Class EventSubscriber.
Namespace
Drupal\config_transformer_testCode
public function onImportTransform(StorageTransformEvent $event) {
$storage = $event
->getStorage();
$site = $storage
->read('system.site');
// Only change something if the sync storage has data.
if (!empty($site)) {
// Add "Arrr" to the site name. Because pirates!
// The site name which is in the sync directory will be ignored.
$current = $this->active
->read('system.site');
$site['name'] = $current['name'] . ' Arrr';
$storage
->write('system.site', $site);
}
}