You are here

public function LocaleSourcePluginUi::overviewSearchFormPart in Translation Management Tool 8

Builds search form for entity sources overview.

Parameters

array $form: Drupal form array.

FormStateInterface $form_state: Drupal form_state array.

string $type: Entity type.

Return value

array Drupal form array.

Overrides SourcePluginUiBase::overviewSearchFormPart

File

sources/locale/src/LocaleSourcePluginUi.php, line 167

Class

LocaleSourcePluginUi
Locale source plugin UI.

Namespace

Drupal\tmgmt_locale

Code

public function overviewSearchFormPart(array $form, FormStateInterface $form_state, $type) {
  $form = parent::overviewSearchFormPart($form, $form_state, $type);
  $options = array();
  foreach (\Drupal::languageManager()
    ->getLanguages() as $langcode => $language) {
    $options[$langcode] = $language
      ->getName();
  }
  $default_values = $this
    ->getSearchFormSubmittedParams();
  $contexts = $this
    ->getContexts();
  $form['search_wrapper']['search']['label'] = array(
    '#type' => 'textfield',
    '#title' => t('Source text'),
    '#default_value' => isset($default_values['label']) ? $default_values['label'] : NULL,
  );

  // Unset English as it is the source language for all locale strings.
  unset($options['en']);
  $form['search_wrapper']['search']['missing_target_language'] = array(
    '#type' => 'select',
    '#title' => t('Not translated to'),
    '#options' => $options,
    '#empty_option' => '--',
    '#default_value' => isset($default_values['missing_target_language']) ? $default_values['missing_target_language'] : NULL,
  );
  $form['search_wrapper']['search']['context'] = [
    '#type' => 'select',
    '#title' => t('Context'),
    '#empty_option' => '--',
    '#options' => $contexts,
    '#default_value' => isset($default_values['context']) ? $default_values['context'] : NULL,
  ];
  return $form;
}