Overrides Drupal\Core\Entity\EntityFormController::save().
Overrides EntityFormController::save
public function save(array $form, array &$form_state) {
$category = $this->entity;
$status = $category
->save();
$uri = $category
->uri();
if ($status == SAVED_UPDATED) {
drupal_set_message(t('Category %label has been updated.', array(
'%label' => $category
->label(),
)));
watchdog('contact', 'Category %label has been updated.', array(
'%label' => $category
->label(),
), WATCHDOG_NOTICE, l(t('Edit'), $uri['path'] . '/edit'));
}
else {
drupal_set_message(t('Category %label has been added.', array(
'%label' => $category
->label(),
)));
watchdog('contact', 'Category %label has been added.', array(
'%label' => $category
->label(),
), WATCHDOG_NOTICE, l(t('Edit'), $uri['path'] . '/edit'));
}
// Update the default category.
$contact_config = config('contact.settings');
if ($form_state['values']['selected']) {
$contact_config
->set('default_category', $category
->id())
->save();
}
elseif ($contact_config
->get('default_category') == $category
->id()) {
$contact_config
->set('default_category', NULL)
->save();
}
$form_state['redirect'] = 'admin/structure/contact';
}