You are here

function menu_block_post_update_implement_schema_for_follow_and_follow_parent in Menu Block 8

Implement config schema for the menu_block settings follow.

File

./menu_block.post_update.php, line 14
Post update functions for Menu block.

Code

function menu_block_post_update_implement_schema_for_follow_and_follow_parent(&$sandbox = NULL) {
  if (!\Drupal::moduleHandler()
    ->moduleExists('block')) {
    return;
  }
  \Drupal::classResolver(ConfigEntityUpdater::class)
    ->update($sandbox, 'block', function (BlockInterface $block) {
    if (strpos($block
      ->getPluginId(), 'menu_block:') === 0) {
      $block_settings = $block
        ->get('settings');
      $block_settings['follow'] = (bool) $block_settings['follow'];
      $block
        ->set('settings', $block_settings);
      return TRUE;
    }
    return FALSE;
  });
}