You are here

public function BlazyAdminFormatter::buildSettingsForm in Blazy 7

Same name and namespace in other branches
  1. 8.2 src/Form/BlazyAdminFormatter.php \Drupal\blazy\Form\BlazyAdminFormatter::buildSettingsForm()
  2. 8 src/Form/BlazyAdminFormatter.php \Drupal\blazy\Form\BlazyAdminFormatter::buildSettingsForm()

Defines re-usable form elements.

File

src/Form/BlazyAdminFormatter.php, line 13

Class

BlazyAdminFormatter
Provides admin form specific to Blazy admin formatter.

Namespace

Drupal\blazy\Form

Code

public function buildSettingsForm(array &$form, $definition = []) {
  $definition['namespace'] = 'blazy';
  $definition['responsive_image'] = isset($definition['responsive_image']) ? $definition['responsive_image'] : TRUE;
  $forms = isset($definition['forms']) ? $definition['forms'] : [];
  $this
    ->openingForm($form, $definition);

  // This allows Blazy to display texts as a grid, without images.
  if (!empty($forms['image_style']) && !isset($form['image_style'])) {
    $this
      ->imageStyleForm($form, $definition);
  }
  if (!empty($forms['media_switch']) && !isset($form['media_switch'])) {
    $this
      ->mediaSwitchForm($form, $definition);
  }
  if (!empty($forms['grid']) && !isset($form['grid'])) {
    $this
      ->gridForm($form, $definition);

    // Blazy doesn't need complex grid with multiple groups.
    unset($form['preserve_keys'], $form['visible_items']);
    $form['grid']['#description'] = t('The amount of block grid columns for large monitors 64.063em+. <br /><strong>Requires</strong>:<ol><li>Display style.</li><li>A reasonable amount of contents.</li></ol>Leave empty to DIY, or to not build grids.');
  }
  if (!empty($definition['breakpoints']) && !$this
    ->manager()
    ->config('unbreakpoints', FALSE, 'blazy.settings')) {
    $this
      ->breakpointsForm($form, $definition);
  }
  $this
    ->closingForm($form, $definition);
}