Same name and namespace in other branches
  1. 8.9.x core/modules/locale/src/Form/TranslateFormBase.php \Drupal\locale\Form\TranslateFormBase::translateFilterLoadStrings()
  2. 9 core/modules/locale/src/Form/TranslateFormBase.php \Drupal\locale\Form\TranslateFormBase::translateFilterLoadStrings()

Builds a string search query and returns an array of string objects.

Return value

\Drupal\locale\TranslationString[] Array of \Drupal\locale\TranslationString objects.

1 call to TranslateFormBase::translateFilterLoadStrings()
TranslateEditForm::buildForm in core/modules/locale/src/Form/TranslateEditForm.php
Form constructor.

File

core/modules/locale/src/Form/TranslateFormBase.php, line 79

Class

TranslateFormBase
Defines the locale user interface translation form base.

Namespace

Drupal\locale\Form

Code

protected function translateFilterLoadStrings() {
  $filter_values = $this
    ->translateFilterValues();

  // Language is sanitized to be one of the possible options in
  // translateFilterValues().
  $conditions = [
    'language' => $filter_values['langcode'],
  ];
  $options = [
    'pager limit' => 30,
    'translated' => TRUE,
    'untranslated' => TRUE,
  ];

  // Add translation status conditions and options.
  switch ($filter_values['translation']) {
    case 'translated':
      $conditions['translated'] = TRUE;
      if ($filter_values['customized'] != 'all') {
        $conditions['customized'] = $filter_values['customized'];
      }
      break;
    case 'untranslated':
      $conditions['translated'] = FALSE;
      break;
  }
  if (!empty($filter_values['string'])) {
    $options['filters']['source'] = $filter_values['string'];
    if ($options['translated']) {
      $options['filters']['translation'] = $filter_values['string'];
    }
  }
  return $this->localeStorage
    ->getTranslations($conditions, $options);
}