FontYourFaceStyleFilter.php in @font-your-face 8.3
File
src/Plugin/views/filter/FontYourFaceStyleFilter.php
View source
<?php
namespace Drupal\fontyourface\Plugin\views\filter;
use Drupal\views\Plugin\views\filter\StringFilter;
use Drupal\Core\Form\FormStateInterface;
class FontYourFaceStyleFilter extends StringFilter {
protected $alwaysMultiple = TRUE;
public function operators() {
return [
'=' => [
'title' => $this
->t('Is equal to'),
'short' => $this
->t('='),
'method' => 'opEqual',
'values' => 1,
],
];
}
protected function valueForm(&$form, FormStateInterface $form_state) {
$options = [
'All' => '- Any -',
'normal' => $this
->t('Normal'),
'italic' => $this
->t('Italics'),
];
$form['value'] = [
'#type' => 'select',
'#title' => $this
->t('Font Style'),
'#options' => $options,
'#default_value' => $this->value,
];
if ($exposed = $form_state
->get('exposed')) {
$identifier = $this->options['expose']['identifier'];
$user_input = $form_state
->getUserInput();
if (!isset($user_input[$identifier])) {
$user_input[$identifier] = $this->value;
$form_state
->setUserInput($user_input);
}
}
}
}