public function FolderForm::submitForm in Filebrowser 3.x
Same name and namespace in other branches
- 8.2 src/Form/FolderForm.php \Drupal\filebrowser\Form\FolderForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ FolderForm.php, line 93
Class
Namespace
Drupal\filebrowser\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$folder_uri = $this->node->filebrowser->folderPath . $this->relativeRoot . '/' . $form_state
->getValue('folder_name');
$success = \Drupal::service('file_system')
->prepareDirectory($folder_uri, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
if (!$success) {
\Drupal::messenger()
->addError($this
->t('Unable to create this folder, do you have filesystem right to do that ?'));
}
else {
Cache::invalidateTags([
'filebrowser:node:' . $this->node
->id(),
]);
}
$route = $this->common
->redirectRoute($this->relativeFid, $this->node
->id());
$form_state
->setRedirect($route['name'], $route['node'], $route['query']);
}