You are here

public function GoogleTranslatorUi::buildConfigurationForm in TMGMT Translator Google 8

Overrides TMGMTDefaultTranslatorUIController::pluginSettingsForm().

Overrides TranslatorPluginUiBase::buildConfigurationForm

File

src/GoogleTranslatorUi.php, line 21
Contains \Drupal\tmgmt_google\GoogleTranslatorUi.

Class

GoogleTranslatorUi
Google translator UI.

Namespace

Drupal\tmgmt_google

Code

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

  /** @var \Drupal\tmgmt\TranslatorInterface $translator */
  $translator = $form_state
    ->getFormObject()
    ->getEntity();
  $form['api_key'] = array(
    '#type' => 'textfield',
    '#title' => t('Google API key'),
    '#required' => TRUE,
    '#default_value' => $translator
      ->getSetting('api_key'),
    '#description' => t('Please enter your Google API key or visit <a href="@url">Google APIs console</a> to create new one.', array(
      '@url' => 'https://code.google.com/apis/console',
    )),
  );
  $form['url'] = array(
    '#type' => 'hidden',
    '#default_value' => $translator
      ->getSetting('url'),
  );
  $form += parent::addConnectButton();
  return $form;
}