ViewsJsonArgument.php in Views Json Source 1.x
File
src/Plugin/views/argument/ViewsJsonArgument.php
View source
<?php
namespace Drupal\views_json_source\Plugin\views\argument;
use Drupal\views\Plugin\views\argument\ArgumentPluginBase;
use Drupal\Core\Form\FormStateInterface;
class ViewsJsonArgument extends ArgumentPluginBase {
public function query($group_by = FALSE) {
$this->query
->addFilter($this);
}
public function generate() {
$operator = "=";
$key = $this->options['key'];
$value = $this->argument;
return [
$key,
$operator,
$value,
];
}
protected function defineOptions() {
$options = parent::defineOptions();
$options['key'] = [
'default' => '',
];
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['key'] = [
'#title' => $this
->t('Key Chooser'),
'#description' => $this
->t('choose a key'),
'#type' => 'textfield',
'#default_value' => $this->options['key'],
'#required' => TRUE,
];
}
}