v1/web/modules/contrib/block_visibility_groups/block_visibility_groups.ins...

25 lines
726 B
PHP

<?php
/**
* @file
* Install, update and uninstall functions for the block_visibility_groups module.
*/
/**
* Implements hook_uninstall().
*/
function block_visibility_groups_uninstall() {
// Remove the 'condition_group' condition from all blocks.
/** @var \Drupal\Core\Entity\EntityStorageInterface $block_storage */
$block_storage = \Drupal::service('entity_type.manager')->getStorage('block');
/** @var \Drupal\block\Entity\Block[] $blocks */
$blocks = $block_storage->loadMultiple();
foreach ($blocks as $block) {
$conditions = $block->getVisibilityConditions();
if ($conditions->has('condition_group')) {
$conditions->removeInstanceId('condition_group');
$block->save();
}
}
}