Created
November 19, 2021 14:20
-
-
Save levmyshkin/13b5724137fbd6a220052b73a12ae4a5 to your computer and use it in GitHub Desktop.
Extending custom Drupal Views filter handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\did_this_help\Plugin\views\filter; | |
use Drupal\views\Plugin\views\filter\InOperator; | |
/** | |
* Filters by given list of yes/no options. | |
* | |
* @ingroup views_filter_handlers | |
* | |
* @ViewsFilter("did_this_help") | |
*/ | |
class DidThisHelp extends InOperator { | |
/** | |
* {@inheritdoc} | |
*/ | |
public function getValueOptions() { | |
if (isset($this->valueOptions)) { | |
return $this->valueOptions; | |
} | |
$this->valueOptions = [ | |
'yes' => $this->t('Yes'), | |
'no' => $this->t('No'), | |
]; | |
return $this->valueOptions; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment