public function BlockListController::submitForm

Implements \Drupal\Core\Form\FormInterface::submitForm().

Form submission handler for the main block administration form.

Overrides FormInterface::submitForm

File

drupal/core/modules/block/lib/Drupal/block/BlockListController.php, line 288
Contains \Drupal\block\BlockListController.

Class

BlockListController
Defines the block list controller.

Namespace

Drupal\block

Code

public function submitForm(array &$form, array &$form_state) {
  $entities = entity_load_multiple('block', array_keys($form_state['values']['blocks']));
  foreach ($entities as $entity_id => $entity) {
    $entity
      ->set('weight', $form_state['values']['blocks'][$entity_id]['weight']);
    $entity
      ->set('region', $form_state['values']['blocks'][$entity_id]['region']);
    if ($entity
      ->get('region') == BLOCK_REGION_NONE) {
      $entity
        ->disable();
    }
    else {
      $entity
        ->enable();
    }
    $entity
      ->save();
  }
  drupal_set_message(t('The block settings have been updated.'));
  cache_invalidate_tags(array(
    'content' => TRUE,
  ));
}