You are here

public function SlickAdmin::buildSettingsForm in Slick Carousel 8

Same name and namespace in other branches
  1. 8.2 src/Form/SlickAdmin.php \Drupal\slick\Form\SlickAdmin::buildSettingsForm()
  2. 7.3 src/Form/SlickAdmin.php \Drupal\slick\Form\SlickAdmin::buildSettingsForm()

Returns the main form elements.

File

src/Form/SlickAdmin.php, line 74

Class

SlickAdmin
Provides resusable admin functions, or form elements.

Namespace

Drupal\slick\Form

Code

public function buildSettingsForm(array &$form, $definition = []) {
  $definition['caches'] = isset($definition['caches']) ? $definition['caches'] : TRUE;
  $definition['namespace'] = 'slick';
  $definition['optionsets'] = isset($definition['optionsets']) ? $definition['optionsets'] : $this
    ->getOptionsetsByGroupOptions('main');
  $definition['skins'] = isset($definition['skins']) ? $definition['skins'] : $this
    ->getSkinsByGroupOptions('main');
  $definition['responsive_image'] = isset($definition['responsive_image']) ? $definition['responsive_image'] : TRUE;
  foreach ([
    'optionsets',
    'skins',
  ] as $key) {
    if (isset($definition[$key]['default'])) {
      ksort($definition[$key]);
      $definition[$key] = [
        'default' => $definition[$key]['default'],
      ] + $definition[$key];
    }
  }
  if (empty($definition['no_layouts'])) {
    $definition['layouts'] = isset($definition['layouts']) ? array_merge($this
      ->getLayoutOptions(), $definition['layouts']) : $this
      ->getLayoutOptions();
  }
  $this
    ->openingForm($form, $definition);
  if (!empty($definition['image_style_form']) && !isset($form['image_style'])) {
    $this
      ->imageStyleForm($form, $definition);
  }
  if (!empty($definition['media_switch_form']) && !isset($form['media_switch'])) {
    $this
      ->mediaSwitchForm($form, $definition);
  }
  if (!empty($definition['grid_form']) && !isset($form['grid'])) {
    $this
      ->gridForm($form, $definition);
  }
  if (!empty($definition['fieldable_form']) && !isset($form['image'])) {
    $this
      ->fieldableForm($form, $definition);
  }
  if (!empty($definition['breakpoints'])) {
    $this->blazyAdmin
      ->breakpointsForm($form, $definition);
  }
  if (!empty($definition['style']) && isset($form['style']['#description'])) {
    $form['style']['#description'] .= ' ' . $this
      ->t('CSS3 Columns is best with adaptiveHeight, non-vertical. Will use regular carousel as default style if left empty. Yet, both CSS3 Columns and Grid Foundation are respected as Grid displays when <strong>Grid large</strong> option is provided.');
  }
  $this
    ->closingForm($form, $definition);
}