public function InstallHelper::deleteImportedContent in Drupal 8
Same name and namespace in other branches
- 9 core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php \Drupal\demo_umami_content\InstallHelper::deleteImportedContent()
Deletes any content imported by this module.
Return value
$this
File
- core/
profiles/ demo_umami/ modules/ demo_umami_content/ src/ InstallHelper.php, line 796
Class
- InstallHelper
- Defines a helper class for importing default content.
Namespace
Drupal\demo_umami_contentCode
public function deleteImportedContent() {
$uuids = $this->state
->get('demo_umami_content_uuids', []);
$by_entity_type = array_reduce(array_keys($uuids), function ($carry, $uuid) use ($uuids) {
$entity_type_id = $uuids[$uuid];
$carry[$entity_type_id][] = $uuid;
return $carry;
}, []);
foreach ($by_entity_type as $entity_type_id => $entity_uuids) {
$storage = $this->entityTypeManager
->getStorage($entity_type_id);
$entities = $storage
->loadByProperties([
'uuid' => $entity_uuids,
]);
$storage
->delete($entities);
}
return $this;
}