HEX
Server: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips
System: Linux WORDPRESS 3.10.0-1160.118.1.el7.x86_64 #1 SMP Thu Apr 4 03:33:23 EDT 2024 x86_64
User: digital (1020)
PHP: 7.2.24
Disabled: NONE
Upload Files
File: /datos/www/fabricas.colombiatrade.com.co/public_html/modules/contrib/blockgroup/blockgroup.install
<?php

/**
 * @file
 *   Blockgroup install file.
 */

/**
 * Updated blockgroup plugin IDs in block placements.
 */
function blockgroup_update_8100() {
  /** @var \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository */
  $entity_repository = \Drupal::service('entity.repository');
  $config_factory = \Drupal::configFactory();
  $update_count = 0;
  foreach ($config_factory->listAll('block.block.') as $config_name) {
    $config = $config_factory->getEditable($config_name);
    $needs_save = FALSE;
    foreach (['plugin', 'settings.id'] as $key) {
      $value = $config->get($key);
      $parts = explode(':', $value, 2);
      if (count($parts) === 2 && $parts[0] === 'block_group') {
        $block_group = $entity_repository->loadEntityByUuid('block_group_content', $parts[1]);
        $block_group_id = $block_group->id();
        $new_value = "block_group:$block_group_id";
        $config->set($key, $new_value);
        $update_count += 1;
        $needs_save = TRUE;
      }
    }
    // Mark as trusted to not trigger further processing.
    if ($needs_save) {
      $config->save(TRUE);
    }
  }
  return "Updated $update_count blockgroup plugin IDs (2 per block) in block placements.";
}