UserConsentState.php in Data Policy 8
File
src/Plugin/views/filter/UserConsentState.php
View source
<?php
namespace Drupal\data_policy\Plugin\views\filter;
use Drupal\data_policy\Entity\UserConsentInterface;
use Drupal\views\Plugin\views\filter\InOperator;
class UserConsentState extends InOperator {
public function getValueOptions() {
if (isset($this->valueOptions)) {
return $this->valueOptions;
}
$this->valueOptions = [
UserConsentInterface::STATE_AGREE => $this
->t('Agree'),
UserConsentInterface::STATE_NOT_AGREE => $this
->t('Not agree'),
UserConsentInterface::STATE_UNDECIDED => $this
->t('Undecided'),
];
return $this->valueOptions;
}
protected function exposedTranslate(&$form, $type) {
$form['#no_convert'] = TRUE;
parent::exposedTranslate($form, $type);
}
protected function opSimple() {
foreach ($this->value as $key => $value) {
if (!is_string($value)) {
unset($this->value[$key]);
}
}
parent::opSimple();
}
}