cheeseburger_menu.install in Cheeseburger Menu 8.4
File
cheeseburger_menu.install
View source
<?php
function cheeseburger_menu_update_8001(&$sandbox) {
$blocks = \Drupal::entityTypeManager()
->getStorage('block')
->loadByProperties([
'plugin' => 'cheesebuger_menu_block',
]);
foreach ($blocks as $block) {
$settings = $block
->get('settings');
foreach ($settings['menu'] as $id => &$data) {
if ($data['title'] == 2) {
$data['title'] = 'do_not_show';
}
elseif ($data['title'] == 1) {
$data['title'] = 'use_default';
}
else {
$data['title'] = 'manual';
}
if (!array_key_exists('collapsible_title', $data)) {
$data['collapsible_title'] = FALSE;
}
}
if (array_key_exists('vocabulary', $settings)) {
$settings['taxonomy_vocabulary'] = $settings['vocabulary'];
unset($settings['vocabulary']);
foreach ($settings['taxonomy_vocabulary'] as $id => &$data) {
if ($data['title'] == 2) {
$data['title'] = 'do_not_show';
}
elseif ($data['title'] == 1) {
$data['title'] = 'use_default';
}
else {
$data['title'] = 'manual';
}
if (!array_key_exists('collapsible_title', $data)) {
$data['collapsible_title'] = FALSE;
}
}
}
if (in_array('all', $settings['breakpoints'])) {
$settings['breakpoints']['all'] = TRUE;
}
elseif (!array_key_exists('all', $settings['breakpoints'])) {
$settings['breakpoints']['all'] = FALSE;
}
$block
->set('settings', $settings);
$block
->save();
}
}