You are here

public function PhotosAdminSettingsForm::submitForm in Album Photos 8.4

Same name and namespace in other branches
  1. 8.5 src/Form/PhotosAdminSettingsForm.php \Drupal\photos\Form\PhotosAdminSettingsForm::submitForm()
  2. 6.0.x 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 559

Class

PhotosAdminSettingsForm
Defines a form to configure maintenance settings for this site.

Namespace

Drupal\photos\Form

Code

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[$form_state
        ->getValue('photos_size_' . $i)] = $form_state
        ->getValue('photos_name_' . $i);
    }
  }
  $photos_size = $size;

  // Set number of albums per role.
  $num = $form_state
    ->getValue('num');
  foreach ($num as $rnum => $rcount) {
    $this
      ->config('photos.settings')
      ->set($rnum, $rcount);
  }
  $this
    ->config('photos.settings')
    ->set('photos_access_photos', $form_state
    ->getValue('photos_access_photos'))
    ->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_comment', $form_state
    ->getValue('photos_comment'))
    ->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_exif', $form_state
    ->getValue('photos_exif'))
    ->set('photos_exif_cache', $form_state
    ->getValue('photos_exif_cache'))
    ->set('photos_image_count', $form_state
    ->getValue('photos_image_count'))
    ->set('photos_num', $form_state
    ->getValue('photos_num'))
    ->set('photos_pager_imagesize', $form_state
    ->getValue('photos_pager_imagesize'))
    ->set('photos_path', $form_state
    ->getValue('photos_path'))
    ->set('photos_plupload_status', $form_state
    ->getValue('photos_plupload_status'))
    ->set('photos_private_file_styles', $form_state
    ->getValue('photos_private_file_styles'))
    ->set('photos_rname', $form_state
    ->getValue('photos_rname'))
    ->set('photos_size', $photos_size)
    ->set('photos_size_max', $form_state
    ->getValue('photos_size_max'))
    ->set('photos_upzip', $form_state
    ->getValue('photos_upzip'))
    ->set('photos_user_count_cron', $form_state
    ->getValue('photos_user_count_cron'))
    ->save();

  // Set warning if private file path is not set.
  if (!PrivateStream::basePath() && $form_state
    ->getValue('photos_access_photos')) {
    \Drupal::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.'));
  }
}