You are here

public function LingotekManagementFormBase::filterForm in Lingotek Translation 3.6.x

Same name and namespace in other branches
  1. 8.2 src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::filterForm()
  2. 4.0.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::filterForm()
  3. 3.0.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::filterForm()
  4. 3.1.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::filterForm()
  5. 3.2.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::filterForm()
  6. 3.3.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::filterForm()
  7. 3.4.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::filterForm()
  8. 3.5.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::filterForm()
  9. 3.7.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::filterForm()
  10. 3.8.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::filterForm()

Form submission handler for filtering.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

File

src/Form/LingotekManagementFormBase.php, line 451

Class

LingotekManagementFormBase
Form for bulk management of content.

Namespace

Drupal\lingotek\Form

Code

public function filterForm(array &$form, FormStateInterface $form_state) {

  /** @var \Drupal\user\PrivateTempStore $temp_store */
  $temp_store = $this->tempStoreFactory
    ->get($this
    ->getTempStorageFilterKey());
  $keys = $this
    ->getFilterKeys();
  $trimmableKeys = [
    'label',
  ];
  foreach ($keys as $key) {
    if (in_array($key[1], $trimmableKeys)) {
      $form_state
        ->setValue([
        'filters',
        $key[0],
        $key[1],
      ], trim($form_state
        ->getValue([
        'filters',
        $key[0],
        $key[1],
      ])));
    }

    // This sets and gets the values of the specific key. $key[0] can be either 'wrapper' or 'advanced_filters', and $key[1] is the specific filter itself.
    $temp_store
      ->set($key[1], $form_state
      ->getValue([
      'filters',
      $key[0],
      $key[1],
    ]));
  }

  // If we apply any filters, we need to go to the first page again.
  $form_state
    ->setRedirect('<current>');
}