function ImporterTest::onPreEntityImport
Modify entity data before it is imported.
Parameters
\Drupal\Core\DefaultContent\PreEntityImportEvent $event: The event being handled.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ DefaultContent/ ImporterTest.php, line 60
Class
- ImporterTest
- Tests the Default Content Importer.
Namespace
Drupal\KernelTests\Core\DefaultContentCode
public function onPreEntityImport(PreEntityImportEvent $event) : void {
self::assertSame('entity_test', $event->metadata['entity_type']);
if ($event->metadata['uuid'] === '01234567-89ab-cdef-0123-456789abcdef') {
$event->data['default']['name'] = [
[
'value' => 'Changed name',
],
];
}
// Anything we put in `_meta` should be discarded.
$event->data['_meta']['entity_type'] = 'This will be ignored.';
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.