public function CheeseburgerMenu::blockSubmit in Cheeseburger Menu 8.3
Same name and namespace in other branches
- 8.4 src/Plugin/Block/CheeseburgerMenu.php \Drupal\cheeseburger_menu\Plugin\Block\CheeseburgerMenu::blockSubmit()
- 8 src/Plugin/Block/CheeseburgerMenu.php \Drupal\cheeseburger_menu\Plugin\Block\CheeseburgerMenu::blockSubmit()
- 8.2 src/Plugin/Block/CheeseburgerMenu.php \Drupal\cheeseburger_menu\Plugin\Block\CheeseburgerMenu::blockSubmit()
Sends and store the block by collected data.
Overrides BlockPluginTrait::blockSubmit
File
- src/
Plugin/ Block/ CheeseburgerMenu.php, line 523 - Cheeseburger class extends BlockBase.
Class
- CheeseburgerMenu
- Block info.
Namespace
Drupal\cheeseburger_menu\Plugin\BlockCode
public function blockSubmit($form, FormStateInterface $form_state) {
parent::blockSubmit($form, $form_state);
$values = $form_state
->getValues();
$controller = new RenderCheeseburgerMenuBlock($this->renderer, $this->menuTree, $this->themeHandler, $this->breakPointManager);
$menus = $controller
->getAllMenuLinkId();
$taxonomies = $controller
->getAllTaxonomyTermIds();
$breakpoints = $controller
->returnBreakpointsForDefaultTheme();
$taxonomiesConf = [];
$taxonomiesWeight = [];
$taxonomyTitles = [];
// Getting menus which will be shown.
foreach ($menus as $id) {
if ($values['menu_fieldset'][$id . '_container'][$id . '_checkbox'] == 1) {
$menusConf[$id] = 1;
$menusWeight[$id] = $values['menu_fieldset'][$id . '_weight'];
$menusTitle = $values['menu_fieldset'][$id . '_title'];
if ($menusTitle == 0) {
$menusTitles[$id] = FALSE;
}
elseif ($menusTitle == 1) {
$menusTitles[$id] = TRUE;
}
elseif ($menusTitle == 2) {
$menusTitles[$id] = $values['menu_fieldset'][$id . '_manual_title'];
}
}
}
// Getting taxonomies which will be shown.
foreach ($taxonomies as $id) {
if ($values['taxonomies'][$id . '_container'][$id . '_checkbox'] == 1) {
$taxonomiesConf[$id] = 1;
$taxonomiesWeight[$id] = $values['taxonomies'][$id . '_weight'];
$taxonomyTitle = $values['taxonomies'][$id . '_title'];
if ($taxonomyTitle == 0) {
$taxonomyTitles[$id] = FALSE;
}
elseif ($taxonomyTitle == 1) {
$taxonomyTitles[$id] = TRUE;
}
elseif ($taxonomyTitle == 2) {
$taxonomyTitles[$id] = $values['taxonomies'][$id . '_manual_title'];
}
}
}
$breakpointsConf = [];
if ($values['breakpoint_fieldset_data']['all'] == 1) {
$this->configuration['breakpoint_all'] = FALSE;
foreach ($breakpoints as $name => $breakpoint) {
if (strtolower($breakpoint['label']) == 'all') {
continue;
}
if ($values['breakpoint_fieldset_data']['breakpoint_checkbox_' . $name] == 1) {
$help_array = [];
$help_array['name'] = $name;
$help_array['mediaQuery'] = $breakpoint['mediaQuery'];
$breakpointsConf[] = $help_array;
}
else {
$help_array = [];
$help_array['name'] = FALSE;
$help_array['mediaQuery'] = $breakpoint['mediaQuery'];
$breakpointsConf[] = $help_array;
}
}
}
else {
$this->configuration['breakpoint_all'] = TRUE;
}
$this->configuration['menus_appear'] = $menusConf;
$this->configuration['menus_weight'] = $menusWeight;
$this->configuration['menus_title'] = $menusTitles;
$this->configuration['taxonomy_appear'] = $taxonomiesConf;
$this->configuration['taxonomy_weight'] = $taxonomiesWeight;
$this->configuration['taxonomy_title'] = $taxonomyTitles;
if (array_key_exists('cart', $values['additional_options'])) {
$this->configuration['cart_appear'] = $values['additional_options']['cart'];
$this->configuration['cart_weight'] = $values['additional_options']['cart_weight'];
}
$this->configuration['phone_appear'] = $values['additional_options']['phone'];
$this->configuration['phone_weight'] = $values['additional_options']['phone_weight'];
$this->configuration['phone_store'] = $values['additional_options']['phone_store'];
$this->configuration['phone_number'] = $values['additional_options']['phone_number'];
$this->configuration['lang_switcher'] = isset($values['lang_switcher_checkbox']) ? $values['lang_switcher_checkbox'] : FALSE;
$this->configuration['lang_switcher_weight'] = isset($values['language_switcher_weight']) ? $values['language_switcher_weight'] : 0;
$this->configuration['css_default'] = $values['css_default'];
$this->configuration['headerHeight'] = $values['headerHeight'];
$this->configuration['headerPadding'] = $values['headerPadding'];
$this->configuration['breakpoints'] = $breakpointsConf;
}