public function ConfigSplitEntityForm::save in Configuration Split 8
Same name and namespace in other branches
- 2.0.x src/Form/ConfigSplitEntityForm.php \Drupal\config_split\Form\ConfigSplitEntityForm::save()
Form submission handler for the 'save' action.
Normally this method should be overridden to provide specific messages to the user and redirect the form after the entity has been saved.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.
Overrides EntityForm::save
File
- src/
Form/ ConfigSplitEntityForm.php, line 343
Class
- ConfigSplitEntityForm
- The entity form.
Namespace
Drupal\config_split\FormCode
public function save(array $form, FormStateInterface $form_state) {
$config_split = $this->entity;
$status = $config_split
->save();
switch ($status) {
case SAVED_NEW:
$this
->messenger()
->addStatus($this
->t('Created the %label Configuration Split setting.', [
'%label' => $config_split
->label(),
]));
break;
default:
$this
->messenger()
->addStatus($this
->t('Saved the %label Configuration Split setting.', [
'%label' => $config_split
->label(),
]));
}
$folder = $form_state
->getValue('folder');
if (!empty($folder) && !file_exists($folder)) {
$this
->messenger()
->addWarning($this
->t('The storage path "%path" for %label Configuration Split setting does not exist. Make sure it exists and is writable.', [
'%label' => $config_split
->label(),
'%path' => $folder,
]));
}
$form_state
->setRedirectUrl($config_split
->toUrl('collection'));
}