3 namespace Drupal\fontyourface\Plugin\views\filter;
5 use Drupal\views\Plugin\views\filter\StringFilter;
6 use Drupal\Core\Form\FormStateInterface;
9 * Filter handler which allows to search based on font styles.
11 * @ingroup views_filter_handlers
13 * @ViewsFilter("fontyourface_font_style")
15 class FontYourFaceStyleFilter extends StringFilter {
18 * Exposed filter options.
22 protected $alwaysMultiple = TRUE;
25 * Provide simple equality operator.
27 public function operators() {
30 'title' => $this->t('Is equal to'),
31 'short' => $this->t('='),
32 'method' => 'opEqual',
41 protected function valueForm(&$form, FormStateInterface $form_state) {
44 'normal' => $this->t('Normal'),
45 'italic' => $this->t('Italics'),
50 '#title' => $this->t('Font Style'),
51 '#options' => $options,
52 '#default_value' => $this->value,
55 if ($exposed = $form_state->get('exposed')) {
56 $identifier = $this->options['expose']['identifier'];
57 $user_input = $form_state->getUserInput();
58 if (!isset($user_input[$identifier])) {
59 $user_input[$identifier] = $this->value;
60 $form_state->setUserInput($user_input);