public function ModuleBuilderComponentFormBase::save in Module Builder 7.2
File
- includes/
module_builder.form.inc, line 801
Class
- ModuleBuilderComponentFormBase
- Backport of ComponentFormBase from 8.x-3.x version.
Code
public function save(array $form, FormStateInterface $form_state) {
$is_new = $this->entity
->isNew();
$module = $this->entity;
$status = $module
->save();
if ($status) {
// Setting the success message.
drupal_set_message($this
->t('Saved the module: @name.', array(
'@name' => $module->name,
)));
}
else {
drupal_set_message($this
->t('The @name module was not saved.', array(
'@name' => $module->name,
)));
}
// Optionally advance to next tab or go to the generate page.
$element = $form_state
->getTriggeringElement();
switch ($element['#mb_action']) {
case 'submit':
$operation = $this
->getOperation();
// For a new module, we need to redirect to its edit form, as staying
// put would leave on the add form.
if ($operation == 'add') {
$operation = 'edit';
}
// For an existing module, we also redirect so that changing the machine
// name of the module goes to the new URL.
$url = $module
->toUrl($operation . '-form');
$form_state
->setRedirectUrl($url);
break;
case 'submit_next':
$next_link = $this
->getNextLink();
$url = $module
->toUrl($next_link);
$form_state
->setRedirectUrl($url);
break;
case 'submit_generate':
$url = $module
->toUrl('generate-form');
$form_state
->setRedirectUrl($url);
break;
}
}