public function PhotosAdminLegacySettingsForm::submitForm in Album Photos 6.0.x
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/ PhotosAdminLegacySettingsForm.php, line 396
Class
- PhotosAdminLegacySettingsForm
- 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);
// Build $photos_size array.
$size = [];
for ($i = 0; $i < $form_state
->getValue('photos_thumb_count'); $i++) {
if ($form_state
->getValue('photos_size_' . $i)) {
$size[] = [
'name' => $form_state
->getValue('photos_name_' . $i),
'style' => $form_state
->getValue('photos_size_' . $i),
];
}
}
$photos_size = $size;
// Check current legacy setting and clear cache if changed.
$currentLegacySetting = $this
->config('photos.settings')
->get('photos_legacy_view_mode');
$this
->config('photos.settings')
->set('photos_additional_sizes', $form_state
->getValue('photos_additional_sizes'))
->set('photos_album_column_count', $form_state
->getValue('photos_album_column_count'))
->set('photos_album_display_type', $form_state
->getValue('photos_album_display_type'))
->set('photos_cover_imagesize', $form_state
->getValue('photos_cover_imagesize'))
->set('photos_display_colorbox_max_height', $form_state
->getValue('photos_display_colorbox_max_height'))
->set('photos_display_colorbox_max_width', $form_state
->getValue('photos_display_colorbox_max_width'))
->set('photos_display_full_imagesize', $form_state
->getValue('photos_display_full_imagesize'))
->set('photos_display_full_viewnum', $form_state
->getValue('photos_display_full_viewnum'))
->set('photos_display_imageorder', $form_state
->getValue('photos_display_imageorder'))
->set('photos_display_list_imagesize', $form_state
->getValue('photos_display_list_imagesize'))
->set('photos_display_page_display', $form_state
->getValue('photos_display_page_display'))
->set('photos_display_page_user', $form_state
->getValue('photos_display_page_user'))
->set('photos_display_teaser_display', $form_state
->getValue('photos_display_teaser_display'))
->set('photos_display_teaser_imagesize', $form_state
->getValue('photos_display_teaser_imagesize'))
->set('photos_display_teaser_user', $form_state
->getValue('photos_display_teaser_user'))
->set('photos_display_teaser_viewnum', $form_state
->getValue('photos_display_teaser_viewnum'))
->set('photos_display_user', $form_state
->getValue('photos_display_user'))
->set('photos_display_view_imagesize', $form_state
->getValue('photos_display_view_imagesize'))
->set('photos_display_viewpager', $form_state
->getValue('photos_display_viewpager'))
->set('photos_legacy_view_mode', $form_state
->getValue('photos_legacy_view_mode'))
->set('photos_pager_imagesize', $form_state
->getValue('photos_pager_imagesize'))
->set('photos_size', $photos_size)
->save();
if ($currentLegacySetting != $form_state
->getValue('photos_legacy_view_mode')) {
$this
->messenger()
->addMessage($this
->t('Cache cleared.'));
drupal_flush_all_caches();
}
}