You are here

public function BynderWidgetBase::getForm in Bynder 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/EntityBrowser/Widget/BynderWidgetBase.php \Drupal\bynder\Plugin\EntityBrowser\Widget\BynderWidgetBase::getForm()
  2. 8.2 src/Plugin/EntityBrowser/Widget/BynderWidgetBase.php \Drupal\bynder\Plugin\EntityBrowser\Widget\BynderWidgetBase::getForm()
  3. 4.0.x src/Plugin/EntityBrowser/Widget/BynderWidgetBase.php \Drupal\bynder\Plugin\EntityBrowser\Widget\BynderWidgetBase::getForm()
2 calls to BynderWidgetBase::getForm()
BynderSearch::getForm in src/Plugin/EntityBrowser/Widget/BynderSearch.php
BynderUpload::getForm in src/Plugin/EntityBrowser/Widget/BynderUpload.php
2 methods override BynderWidgetBase::getForm()
BynderSearch::getForm in src/Plugin/EntityBrowser/Widget/BynderSearch.php
BynderUpload::getForm in src/Plugin/EntityBrowser/Widget/BynderUpload.php

File

src/Plugin/EntityBrowser/Widget/BynderWidgetBase.php, line 145

Class

BynderWidgetBase
Base class for Bynder Entity browser widgets.

Namespace

Drupal\bynder\Plugin\EntityBrowser\Widget

Code

public function getForm(array &$original_form, FormStateInterface $form_state, array $additional_widget_parameters) {
  $form = parent::getForm($original_form, $form_state, $additional_widget_parameters);
  if (!$this
    ->checkType()) {
    $form_state
      ->setValue('errors', TRUE);
    return $form;
  }

  // Check if the API configuration is in place and exit early if not.
  foreach ([
    'consumer_key',
    'consumer_secret',
    'token',
    'token_secret',
    'account_domain',
  ] as $key) {
    if ($this->config
      ->get('bynder.settings')
      ->get($key) === '') {
      $form_state
        ->setValue('errors', TRUE);
      (new UnableToConnectException())
        ->logException()
        ->displayMessage();
      return $form;
    }
  }
  return $form;
}