1 layout.admin.inc layout_block_configure_form_submit($form, &$form_state)

Form submit handler for layout_block_configure_form().

File

core/modules/layout/layout.admin.inc, line 1802
Admin page callbacks for the Layout module.

Code

function layout_block_configure_form_submit($form, &$form_state) {
  /* @var Block $block */
  $block = $form_state['block'];
  /* @var Layout $layout */
  $layout = $form_state['layout'];
  /* @var LayoutStyle $style */
  $style = $form_state['style'];
  /* @var LayoutRendererStandard $renderer */
  $renderer = $form_state['renderer'];
  $block_plugin = $block->plugin;

  // Save the block settings.
  $block->formSubmit($form, $form_state);

  // Allow the block to change it's type by updating the plugin.
  if ($block_plugin !== $block->plugin) {
    $old_block = clone $block;
    $block = layout_create_handler('block', $old_block->plugin);
    $block->settings = $old_block->settings;
    $block->uuid = $old_block->uuid;
    $block->conditions = $old_block->conditions;
    $block->style = $old_block->style;
    $block->contexts = $old_block->contexts;
    $block->is_new = TRUE;
    $form_state['block'] = $block;
  }

  // Save the style settings.
  $style->formSubmit($form['style']['style_settings'], $form_state);
  $block->style = $style;

  // Generate a UUID for the block.
  if (empty($block->uuid)) {
    $uuid = new Uuid();
    $block->uuid = $uuid->generate();
  }

  // Temporarily store any unfinished blocks (those that do not yet have a
  // position but were just added) in the layout so it can be retrieved. See
  // layout_tempstore_block_load().
  if (!empty($form_state['triggering_element']['#save_in_progress'])) {
    $layout->in_progress['region_name'] = $form_state['values']['region'];
    $layout->in_progress['block'] = $block;
    $layout->in_progress['renderer'] = $renderer;
  }
  // Insert new blocks into the layout.
  else {
    $layout->content[$block->uuid] = $block;
    if ($form_state['values']['region']) {
      $layout->setBlockPosition($block->uuid, $form_state['values']['region']);
    }
    // Clean up the in_progress value now that we're fully done.
    $layout->in_progress = NULL;
  }

  $form_state['redirect'] = 'admin/structure/layouts/manage/' . $layout->name;
  layout_set_layout_tempstore($layout);
}