public function PhotosAdminSettingsForm::submitForm in Album Photos 6.0.x
Same name and namespace in other branches
- 8.5 src/Form/PhotosAdminSettingsForm.php \Drupal\photos\Form\PhotosAdminSettingsForm::submitForm()
- 8.4 src/Form/PhotosAdminSettingsForm.php \Drupal\photos\Form\PhotosAdminSettingsForm::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 ConfigFormBase::submitForm
File
- src/
Form/ PhotosAdminSettingsForm.php, line 429
Class
- PhotosAdminSettingsForm
- Defines a form to configure maintenance settings for this site.
Namespace
Drupal\photos\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
// Set number of albums per role.
$num = $form_state
->getValue('num');
foreach ($num as $rnum => $rcount) {
$this
->config('photos.settings')
->set($rnum, $rcount);
}
// Check current album photos image list view.
$currentImageListView = $this
->config('photos.settings')
->get('node_field_album_photos_list_view');
$currentFormMode = $this
->config('photos.settings')
->get('upload_form_mode');
$this
->config('photos.settings')
->set('album_link_override', $form_state
->getValue('album_link_override'))
->set('album_photo_limit', $form_state
->getValue([
'num',
'album_photo_limit',
]))
->set('upload_form_mode', $form_state
->getValue('upload_form_mode'))
->set('multi_upload_default_field', $form_state
->getValue('multi_upload_default_field'))
->set('node_field_album_photos_list_view', $form_state
->getValue('node_field_album_photos_list_view'))
->set('photos_image_count', $form_state
->getValue('photos_image_count'))
->set('photos_access_photos', $form_state
->getValue('photos_access_photos'))
->set('photos_num', $form_state
->getValue('photos_num'))
->set('photos_plupload_status', $form_state
->getValue('photos_plupload_status'))
->set('photos_size_max', $form_state
->getValue('photos_size_max'))
->set('photos_clean_title', $form_state
->getValue('photos_clean_title'))
->set('photos_upzip', $form_state
->getValue('photos_upzip'))
->set('photos_user_count_cron', $form_state
->getValue('photos_user_count_cron'))
->set('user_albums_link_override', $form_state
->getValue('user_albums_link_override'))
->set('user_images_link_override', $form_state
->getValue('user_images_link_override'))
->save();
// Set warning if private file path is not set.
if (!PrivateStream::basePath() && $form_state
->getValue('photos_access_photos')) {
$this
->messenger()
->addWarning($this
->t('Warning: image files can
still be accessed by visiting the direct URL. For better security, ask
your website admin to setup a private file path.'));
}
if ($currentFormMode != $form_state
->getValue('upload_form_mode')) {
$this->routeBuilder
->rebuild();
}
if ($currentImageListView != $form_state
->getValue('node_field_album_photos_list_view')) {
$this
->messenger()
->addMessage($this
->t('Views node_list and photos_image_list cache cleared.'));
// Clear views cache.
Cache::invalidateTags([
'node_list',
'photos_image_list',
]);
}
}