public function EntityformTypeFormController::save in Entityform 8.2
File
- lib/
Drupal/ entityform/ EntityformTypeFormController.php, line 119 - Contains \Drupal\entityform\EntityformTypeFormController.
Class
- EntityformTypeFormController
- Form controller for entityform type forms.
Namespace
Drupal\entityformCode
public function save(array $form, array &$form_state) {
$type = $this->entity;
$type->type = trim($type
->id());
$type->name = trim($type->name);
$variables = $form_state['values'];
// Do not save settings from vertical tabs.
// @todo Fix vertical_tabs.
unset($variables['additional_settings__active_tab']);
// @todo Remove the entire following code after converting node settings of
// Comment and Menu module. https://drupal.org/node/2026165
// Remove all node type entity properties.
foreach (get_class_vars(get_class($type)) as $key => $value) {
unset($variables[$key]);
}
// Save or reset persistent variable values.
foreach ($variables as $key => $value) {
$variable_new = $key . '_' . $type
->id();
$variable_old = $key . '_' . $type
->getOriginalID();
if (is_array($value)) {
$value = array_keys(array_filter($value));
}
variable_set($variable_new, $value);
if ($variable_new != $variable_old) {
variable_del($variable_old);
}
}
// Saving the entityform type after saving the variables allows modules to act
// on those variables via hook_node_type_insert().
$status = $type
->save();
$t_args = array(
'%name' => $type
->label(),
);
if ($status == SAVED_UPDATED) {
drupal_set_message(t('The entityform type %name has been updated.', $t_args));
}
elseif ($status == SAVED_NEW) {
drupal_set_message(t('The entityform type %name has been added.', $t_args));
watchdog('node', 'Added entityform type %name.', $t_args, WATCHDOG_NOTICE, l(t('view'), 'admin/structure/types'));
}
$form_state['redirect'] = 'admin/structure/entityform-types';
}