You are here

trait BetterExposedFiltersTrait in Better Exposed Filters 8.5

Same name and namespace in other branches
  1. 8.4 tests/src/Traits/BetterExposedFiltersTrait.php \Drupal\Tests\better_exposed_filters\Traits\BetterExposedFiltersTrait

Makes Drupal's test API forward compatible with multiple versions of PHPUnit.

Hierarchy

2 files declare their use of BetterExposedFiltersTrait
BetterExposedFiltersKernelTestBase.php in tests/src/Kernel/BetterExposedFiltersKernelTestBase.php
BetterExposedFiltersTest.php in tests/src/FunctionalJavascript/BetterExposedFiltersTest.php

File

tests/src/Traits/BetterExposedFiltersTrait.php, line 11

Namespace

Drupal\Tests\better_exposed_filters\Traits
View source
trait BetterExposedFiltersTrait {

  /**
   * Returns the configured BEF options.
   *
   * @param \Drupal\views\ViewExecutable $view
   *   The view object.
   *
   * @return array
   *   Array of BEF options.
   */
  protected function &getBetterExposedOptions(ViewExecutable $view) {
    return $view->storage
      ->getDisplay('default')['display_options']['exposed_form']['options']['bef'];
  }

  /**
   * Merges options into existing BEF configuration.
   *
   * @param \Drupal\views\ViewExecutable $view
   *   The view object.
   * @param array $options
   *   The list of options (e.g. ['sort' => ['plugin_id' => 'default']]).
   *
   * @throws \Drupal\Core\Entity\EntityStorageException
   *   In case of failures an exception is thrown.
   */
  protected function setBetterExposedOptions(ViewExecutable $view, array $options) {
    $bef_options =& $this
      ->getBetterExposedOptions($view);
    $bef_options = NestedArray::mergeDeep($bef_options, $options);
    $view->storage
      ->save();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BetterExposedFiltersTrait::getBetterExposedOptions protected function Returns the configured BEF options.
BetterExposedFiltersTrait::setBetterExposedOptions protected function Merges options into existing BEF configuration.