public function ImportSubscriber::onImport in Thunder 8.2
Publish imported articles.
Parameters
\Drupal\default_content\Event\ImportEvent $event: The event entity.
Throws
\Drupal\Core\Entity\EntityStorageException
File
- modules/
thunder_demo/ src/ EventSubscriber/ ImportSubscriber.php, line 22
Class
- ImportSubscriber
- Class ImportSubscriber.
Namespace
Drupal\thunder_demo\EventSubscriberCode
public function onImport(ImportEvent $event) {
$uuids = [
'0bd5c257-2231-450f-b4c2-ab156af7b78d',
'36b2e2b2-3df0-43eb-a282-d792b0999c07',
'94ad928b-3ec8-4bcb-b617-ab1607bf69cb',
'bbb1ee17-15f8-46bd-9df5-21c58040d741',
];
foreach ($event
->getImportedEntities() as $entity) {
if (in_array($entity
->uuid(), $uuids)) {
$entity->moderation_state->value = 'published';
$entity
->save();
}
}
}