You are here

public function PhotosAdminStructureForm::buildForm in Album Photos 6.0.x

Same name and namespace in other branches
  1. 8.5 src/Form/PhotosAdminStructureForm.php \Drupal\photos\Form\PhotosAdminStructureForm::buildForm()

Form constructor.

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

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/PhotosAdminStructureForm.php, line 71

Class

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

Namespace

Drupal\photos\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);

  // Get variables for default values.
  $config = $this
    ->config('photos.settings');

  // Load custom admin css and js library.
  $form['#attached']['library'] = [
    'photos/photos.admin',
  ];

  // Display settings.
  $form['display'] = [
    '#title' => $this
      ->t('Display'),
    '#type' => 'container',
  ];
  $form['display']['description'] = [
    '#markup' => $this
      ->t('Default view modes. Add more custom view modes for Photo here: @display_modes_link and enable them here: @view_modes_link.', [
      '@display_modes_link' => Link::fromTextAndUrl($this
        ->t('View modes'), Url::fromRoute('entity.entity_view_mode.collection'))
        ->toString(),
      '@view_modes_link' => Link::fromTextAndUrl($this
        ->t('photos custom display settings'), Url::fromRoute('entity.entity_view_display.photos_image.default'))
        ->toString(),
    ]),
  ];
  $viewModeOptions = $this->entityDisplayRepository
    ->getViewModeOptionsByBundle('photos_image', 'photos_image');
  $form['display']['view_mode_rearrange_album_page'] = [
    '#title' => $this
      ->t('Rearrange albums page'),
    '#type' => 'select',
    '#options' => $viewModeOptions,
    '#default_value' => $config
      ->get('view_mode_rearrange_album_page') ?: 'sort',
  ];
  $form['display']['view_mode_rearrange_image_page'] = [
    '#title' => $this
      ->t('Rearrange images page'),
    '#type' => 'select',
    '#options' => $viewModeOptions,
    '#default_value' => $config
      ->get('view_mode_rearrange_image_page') ?: 'sort',
  ];
  return parent::buildForm($form, $form_state);
}