BBoxQuery.php in Views GeoJSON 8
File
src/Plugin/views/argument_default/BBoxQuery.php
View source
<?php
declare (strict_types=1);
namespace Drupal\views_geojson\Plugin\views\argument_default;
use Drupal\core\form\FormStateInterface;
use Drupal\views\Plugin\views\argument_default\QueryParameter;
class BBoxQuery extends QueryParameter {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['info'] = [
'#markup' => '<p class="description">Attempt to pull bounding box info
directly from the query string, bypassing Drupal\'s normal argument
handling. If the argument does not exist, all values will be shown.</p>',
];
$form['arg_id'] = [
'#type' => 'textfield',
'#title' => $this
->t('Query argument ID'),
'#size' => 60,
'#maxlength' => 64,
'#default_value' => $this->options['arg_id'] ? $this->options['arg_id'] : $this
->t('bbox'),
'#description' => $this
->t('The ID of the query argument.<br />For OpenLayers use <em>bbox</em>, (as in "<em>?bbox=left,bottom,right,top</em>".)'),
];
}
public function getArgument() {
$current_request = $this->view
->getRequest();
if ($current_request->query
->has($this->options['arg_id'])) {
return $current_request->query
->get($this->options['arg_id']);
}
return $this->options['fallback'];
}
protected function defineOptions() {
$options = parent::defineOptions();
$options['argument'] = [
'default' => '',
];
$options['arg_id'] = [
'default' => 'bbox',
];
return $options;
}
}
Classes
Name |
Description |
BBoxQuery |
The BBOX query string argument default handler. |