public function CustomBlockTypeFormController::save

Overrides \Drupal\Core\Entity\EntityFormController::save().

Overrides EntityFormController::save

File

drupal/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php, line 89
Contains \Drupal\custom_block\CustomBlockTypeFormController.

Class

CustomBlockTypeFormController
Base form controller for category edit forms.

Namespace

Drupal\custom_block

Code

public function save(array $form, array &$form_state) {
  $block_type = $this->entity;
  $status = $block_type
    ->save();
  $uri = $block_type
    ->uri();
  if ($status == SAVED_UPDATED) {
    drupal_set_message(t('Custom block type %label has been updated.', array(
      '%label' => $block_type
        ->label(),
    )));
    watchdog('custom_block', 'Custom block type %label has been updated.', array(
      '%label' => $block_type
        ->label(),
    ), WATCHDOG_NOTICE, l(t('Edit'), $uri['path'] . '/edit'));
  }
  else {
    drupal_set_message(t('Custom block type %label has been added.', array(
      '%label' => $block_type
        ->label(),
    )));
    watchdog('custom_block', 'Custom block type %label has been added.', array(
      '%label' => $block_type
        ->label(),
    ), WATCHDOG_NOTICE, l(t('Edit'), $uri['path'] . '/edit'));
  }
  $form_state['redirect'] = 'admin/structure/custom-blocks';
}