function block_post_update_set_menu_block_depth_to_null_if_zero
Updates the `depth` setting to NULL if it is 0 in any menu blocks.
File
-
core/
modules/ block/ block.post_update.php, line 41
Code
function block_post_update_set_menu_block_depth_to_null_if_zero(array &$sandbox = []) : void {
\Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'block', function (BlockInterface $block) : bool {
if ($block->getPlugin()
->getBaseId() === 'system_menu_block') {
$settings = $block->get('settings');
// Use `empty()` to account for either integer 0, or '0'.
if (empty($settings['depth'])) {
$settings['depth'] = NULL;
}
$block->set('settings', $settings);
return TRUE;
}
return FALSE;
});
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.