public function LayoutChangeRegions::submitForm in Panels 8.4
Same name and namespace in other branches
- 8.3 src/Form/LayoutChangeRegions.php \Drupal\panels\Form\LayoutChangeRegions::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ LayoutChangeRegions.php, line 189
Class
- LayoutChangeRegions
- Provides a form for mapping old regions into the regions of a new layout.
Namespace
Drupal\panels\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$cached_values = $form_state
->getTemporaryValue('wizard');
/** @var \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $plugin */
$plugin = $cached_values['plugin'];
$blocks = $plugin
->getRegionAssignments();
/**
* @var string $region
* @var \Drupal\Core\Block\BlockPluginInterface[] $block_group
*/
foreach ($blocks as $region => $block_group) {
foreach ($block_group as $uuid => $block) {
$new_region = $form_state
->getValue([
'blocks',
'old_' . $region,
'region',
]);
$block
->setConfiguration([
'region' => $new_region,
] + $block
->getConfiguration());
}
}
$layout_id = !empty($cached_values['layout_change']['new_layout']) ? $cached_values['layout_change']['new_layout'] : $plugin
->getConfiguration()['layout'];
$layout_settings = !empty($cached_values['layout_change']['layout_settings']) ? $cached_values['layout_change']['layout_settings'] : [];
$plugin
->setLayout($layout_id, $layout_settings);
unset($cached_values['layout_change']);
$form_state
->setTemporaryValue('wizard', $cached_values);
}