You are here

function block_update_8003 in Drupal 8

Remove 'cache' setting.

File

core/modules/block/block.install, line 103
Contains install and update functions for Block.

Code

function block_update_8003() {
  $config_factory = \Drupal::configFactory();
  foreach ($config_factory
    ->listAll('block.block.') as $block_config_name) {
    $block = $config_factory
      ->getEditable($block_config_name);

    // Remove the 'cache' setting.
    $settings = $block
      ->get('settings');
    unset($settings['cache']);
    $block
      ->set('settings', $settings);

    // Mark the resulting configuration as trusted data. This avoids issues with
    // future schema changes.
    $block
      ->save(TRUE);
  }
  return t('Block settings updated.');
}