class AdministrativeArea in Address 8
Filter by administrative area.
@todo: Rebuild the exposed filter element via AJAX when the country changes.
Plugin annotation
@ViewsFilter("administrative_area");
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\views\Plugin\views\PluginBase implements DependentPluginInterface, ContainerFactoryPluginInterface, TrustedCallbackInterface, ViewsPluginInterface
- class \Drupal\views\Plugin\views\HandlerBase implements ViewsHandlerInterface
- class \Drupal\views\Plugin\views\filter\FilterPluginBase implements CacheableDependencyInterface
- class \Drupal\views\Plugin\views\filter\InOperator
- class \Drupal\address\Plugin\views\filter\CountryAwareInOperatorBase
- class \Drupal\address\Plugin\views\filter\AdministrativeArea
- class \Drupal\address\Plugin\views\filter\CountryAwareInOperatorBase
- class \Drupal\views\Plugin\views\filter\InOperator
- class \Drupal\views\Plugin\views\filter\FilterPluginBase implements CacheableDependencyInterface
- class \Drupal\views\Plugin\views\HandlerBase implements ViewsHandlerInterface
- class \Drupal\views\Plugin\views\PluginBase implements DependentPluginInterface, ContainerFactoryPluginInterface, TrustedCallbackInterface, ViewsPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of AdministrativeArea
See also
https://www.drupal.org/node/2840717
File
- src/
Plugin/ views/ filter/ AdministrativeArea.php, line 24
Namespace
Drupal\address\Plugin\views\filterView source
class AdministrativeArea extends CountryAwareInOperatorBase {
/**
* The address format repository.
*
* @var \CommerceGuys\Addressing\AddressFormat\AddressFormatRepositoryInterface
*/
protected $addressFormatRepository;
/**
* The subdivision repository.
*
* @var \CommerceGuys\Addressing\Subdivision\SubdivisionRepositoryInterface
*/
protected $subdivisionRepository;
/**
* If we're in the middle of building a form, its current state.
*
* @var \Drupal\Core\Form\FormStateInterface
*/
protected $formState;
/**
* The currently selected country (if any).
*
* @var string
*/
protected $currentCountryCode;
/**
* Constructs a new AdministrativeArea object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \CommerceGuys\Addressing\Country\CountryRepositoryInterface $country_repository
* The country repository.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
* The entity field manager.
* @param \CommerceGuys\Addressing\AddressFormat\AddressFormatRepositoryInterface $address_format_repository
* The address format repository.
* @param \CommerceGuys\Addressing\Subdivision\SubdivisionRepositoryInterface $subdivision_repository
* The subdivision repository.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, CountryRepositoryInterface $country_repository, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, AddressFormatRepositoryInterface $address_format_repository, SubdivisionRepositoryInterface $subdivision_repository) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $country_repository, $entity_type_manager, $entity_field_manager);
$this->addressFormatRepository = $address_format_repository;
$this->subdivisionRepository = $subdivision_repository;
$this->formState = NULL;
$this->currentCountryCode = '';
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('address.country_repository'), $container
->get('entity_type.manager'), $container
->get('entity_field.manager'), $container
->get('address.address_format_repository'), $container
->get('address.subdivision_repository'));
}
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['country'] = [
'contains' => [
'country_source' => [
'default' => '',
],
'country_argument_id' => [
'default' => '',
],
'country_filter_id' => [
'default' => '',
],
'country_static_code' => [
'default' => '',
],
],
];
$options['expose']['contains']['label_type']['default'] = 'static';
return $options;
}
/**
* {@inheritdoc}
*/
protected function canBuildGroup() {
// To be able to define a group, you have to be able to select values
// while configuring the filter. But this filter doesn't let you select
// values until a country is selected, so the group filter functionality
// is impossible.
return FALSE;
}
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$this->formState = $form_state;
$form['country'] = [
'#type' => 'container',
'#weight' => -300,
];
$form['country']['country_source'] = [
'#type' => 'radios',
'#title' => $this
->t('Country source'),
'#options' => [
'static' => $this
->t('A predefined country code'),
'argument' => $this
->t('The value of a contextual filter'),
'filter' => $this
->t('The value of an exposed filter'),
],
'#default_value' => $this->options['country']['country_source'],
'#ajax' => [
'callback' => [
get_class($this),
'ajaxRefreshCountry',
],
'wrapper' => 'admin-area-value-options-ajax-wrapper',
],
];
$argument_options = [];
// Find all the contextual filters on the display to use as options.
foreach ($this->view->display_handler
->getHandlers('argument') as $name => $argument) {
// @todo Limit this to arguments pointing to a country code field.
// @see https://www.drupal.org/project/address/issues/3088084
$argument_options[$name] = $argument
->adminLabel();
}
if (!empty($argument_options)) {
$form['country']['country_argument_id'] = [
'#type' => 'select',
'#title' => $this
->t('Country contextual filter'),
'#options' => $argument_options,
'#default_value' => $this->options['country']['country_argument_id'],
];
}
else {
// #states doesn't work on markup elements, so use a container.
$form['country']['country_argument_id'] = [
'#type' => 'container',
];
$form['country']['country_argument_id']['error'] = [
'#type' => 'markup',
'#markup' => $this
->t('You must add a contextual filter for the country code to use this filter for administrative areas.'),
];
}
$form['country']['country_argument_id']['#states'] = [
'visible' => [
':input[name="options[country][country_source]"]' => [
'value' => 'argument',
],
],
];
$filter_options = [];
// Find all country filters from address.module for the valid choices.
foreach ($this->view->display_handler
->getHandlers('filter') as $name => $filter) {
$definition = $filter->pluginDefinition;
// Support both 'country' (current) and 'country_code' (deprecated).
if ($definition['provider'] === 'address' && ($definition['id'] === 'country' || $definition['id'] === 'country_code')) {
$filter_options[$name] = $filter
->adminLabel();
}
}
if (!empty($filter_options)) {
$form['country']['country_filter_id'] = [
'#type' => 'select',
'#title' => $this
->t('Exposed country filter to determine values'),
'#options' => $filter_options,
'#default_value' => $this->options['country']['country_filter_id'],
];
}
else {
// #states doesn't work on markup elements, so we to use a container.
$form['country']['country_filter_id'] = [
'#type' => 'container',
];
$form['country']['country_filter_id']['error'] = [
'#type' => 'markup',
'#markup' => $this
->t('You must add a filter for the country code to use this filter for administrative areas.'),
];
}
$form['country']['country_filter_id']['#states'] = [
'visible' => [
':input[name="options[country][country_source]"]' => [
'value' => 'filter',
],
],
];
$countries = $this
->getAdministrativeAreaCountries();
$form['country']['country_static_code'] = [
'#type' => 'select',
'#title' => $this
->t('Predefined country for administrative areas'),
'#options' => $countries,
'#empty_value' => '',
'#default_value' => $this->options['country']['country_static_code'],
'#ajax' => [
'callback' => [
get_class($this),
'ajaxRefreshCountry',
],
'wrapper' => 'admin-area-value-options-ajax-wrapper',
],
'#states' => [
'visible' => [
':input[name="options[country][country_source]"]' => [
'value' => 'static',
],
],
],
];
// @todo This should appear directly above $form['expose']['label'].
$form['expose']['label_type'] = [
'#type' => 'radios',
'#title' => $this
->t('Label type'),
'#options' => [
'static' => $this
->t('Static'),
'dynamic' => $this
->t('Dynamic (an appropriate label will be set based on the active country)'),
],
'#default_value' => $this->options['expose']['label_type'],
'#states' => [
'visible' => [
':input[name="options[expose_button][checkbox][checkbox]"]' => [
'checked' => TRUE,
],
],
],
];
parent::buildOptionsForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function validateOptionsForm(&$form, FormStateInterface $form_state) {
if (empty($form_state)) {
return;
}
$is_exposed = !empty($this->options['exposed']);
$country_source = $form_state
->getValue([
'options',
'country',
'country_source',
]);
switch ($country_source) {
case 'argument':
$country_argument = $form_state
->getValue([
'options',
'country',
'country_argument_id',
]);
if (empty($country_argument)) {
$error = $this
->t("The country contextual filter must be defined for this filter to work using 'contextual filter' for the 'Country source'.");
$form_state
->setError($form['country']['country_source'], $error);
}
if (empty($is_exposed)) {
$error = $this
->t('This filter must be exposed to use a contextual filter to specify the country.');
$form_state
->setError($form['country']['country_source'], $error);
}
break;
case 'filter':
$country_filter = $form_state
->getValue([
'options',
'country',
'country_filter_id',
]);
if (empty($country_filter)) {
$error = $this
->t("The country filter must be defined for this filter to work using 'exposed filter' for the 'Country source'.");
$form_state
->setError($form['country']['country_source'], $error);
}
if (empty($is_exposed)) {
$error = $this
->t('This filter must be exposed to use a filter to specify the country.');
$form_state
->setError($form['country']['country_source'], $error);
}
break;
case 'static':
$country_code = $form_state
->getValue([
'options',
'country',
'country_static_code',
]);
if (empty($country_code)) {
$error = $this
->t('The predefined country must be set for this filter to work.');
$form_state
->setError($form['country']['country_static_code'], $error);
}
break;
default:
$error = $this
->t('The source for the country must be defined for this filter to work.');
$form_state
->setError($form['country']['country_source'], $error);
break;
}
parent::validateOptionsForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function buildExposeForm(&$form, FormStateInterface $form_state) {
parent::buildExposeForm($form, $form_state);
// Only show the label element if we're configured for a static label.
$form['expose']['label']['#states'] = [
'visible' => [
':input[name="options[expose][label_type]"]' => [
'value' => 'static',
],
],
];
// Only show the reduce option if we have a static country. If we're
// getting values from a filter or argument, there are no fixed values to
// reduce to.
$form['expose']['reduce']['#states'] = [
'visible' => [
':input[name="options[country][country_source]"]' => [
'value' => 'static',
],
],
];
// Repair the wrapper container on $form['value'] clobbered by
// FilterPluginBase::buildExposeForm().
$form['value']['#prefix'] = '<div id="admin-area-value-options-ajax-wrapper" class="views-group-box views-right-60">';
$form['value']['#suffix'] = '</div>';
return $form;
}
/**
* {@inheritdoc}
*/
public function submitExposeForm($form, FormStateInterface $form_state) {
// If the country source is anything other than static, we have to
// ignore/disable the "reduce" option since it doesn't make any sense and
// will cause problems if the stale configuration is saved.
// Similarly, we clear out any selections for specific administrative areas.
$country_source = $form_state
->getValue([
'options',
'country',
'country_source',
]);
if ($country_source != 'static') {
$form_state
->setValue([
'options',
'expose',
'reduce',
], FALSE);
$form_state
->setValue([
'options',
'value',
], []);
}
parent::submitExposeForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
protected function showValueForm(&$form, FormStateInterface $form_state) {
$this
->valueForm($form, $form_state);
$form['value']['#prefix'] = '<div id="admin-area-value-options-ajax-wrapper">';
$form['value']['#suffix'] = '</div>';
}
/**
* {@inheritdoc}
*/
public function valueForm(&$form, FormStateInterface $form_state) {
$this->valueOptions = [];
$this->formState = $form_state;
$country_source = $this
->getCountrySource();
if ($country_source == 'static' || $form_state
->get('exposed')) {
$this
->getCurrentCountry();
parent::valueForm($form, $form_state);
$form['value']['#after_build'][] = [
get_class($this),
'clearValues',
];
}
else {
$form['value'] = [
'#type' => 'container',
'#attributes' => [
'id' => 'admin-area-value-options-ajax-wrapper',
],
];
$form['value']['message'] = [
'#type' => 'markup',
'#markup' => $this
->t("You can only select options here if you use a predefined country for the 'Country source'."),
];
}
}
/**
* {@inheritdoc}
*/
protected function valueSubmit($form, FormStateInterface $form_state) {
$this->formState = $form_state;
$country_source = $this
->getCountrySource();
if ($country_source == 'static') {
// Only save the values if we've got a static country code.
parent::valueSubmit($form, $form_state);
}
}
/**
* {@inheritdoc}
*/
public function exposedInfo() {
$info = parent::exposedInfo();
if ($this->options['expose']['label_type'] == 'dynamic') {
$current_country = $this
->getCurrentCountry();
if (!empty($current_country)) {
$address_format = $this->addressFormatRepository
->get($current_country);
$labels = LabelHelper::getFieldLabels($address_format);
if (!empty($labels['administrativeArea'])) {
$info['label'] = $labels['administrativeArea'];
}
}
}
return $info;
}
/**
* Gets the current source for the country code.
*
* If defined in the current values of the configuration form, use
* that. Otherwise, fall back to the filter configuration.
*
* @return string
* The country source.
*/
protected function getCountrySource() {
// If we're rebuilding via AJAX, we want the country source from the form
// state, not the configuration.
$country_source = '';
if (!empty($this->formState)) {
// First, see if there's a legitimate value in the form state.
$form_value_country_source = $this->formState
->getValue([
'options',
'country',
'country_source',
]);
if (!empty($form_value_country_source)) {
$country_source = $form_value_country_source;
}
else {
// At various stages of building/validating the form, we might have
// user input but not yet have the value saved into the form
// state. So, if we have a form state but still don't have a value,
// see if it is defined in the user input.
$input = $this->formState
->getUserInput();
if (!empty($input['options']['country']['country_source'])) {
$country_source = $input['options']['country']['country_source'];
}
}
}
// If we don't have a source via the form state, use our configuration.
if (empty($country_source)) {
$country_source = $this->options['country']['country_source'];
}
return $country_source;
}
/**
* Gets the currently active country code.
*
* The country source determines where to look for the country code. It can
* either be predefined, in which case we simply return the current value of
* the static country code (via form values or configuration). We can look
* for the country via a Views argument, in which case we determine the
* current value of the argument. Or we can get the country from another
* exposed filter, in which case we look in the form values to find the
* current country code from the other filter.
*
* @return string
* The 2-letter country code.
*/
protected function getCurrentCountry() {
$this->currentCountryCode = '';
switch ($this
->getCountrySource()) {
case 'argument':
$country_argument = $this->view->display_handler
->getHandler('argument', $this->options['country']['country_argument_id']);
if (!empty($country_argument)) {
$this->currentCountryCode = $country_argument
->getValue();
}
break;
case 'filter':
$country_filter = $this->view->display_handler
->getHandler('filter', $this->options['country']['country_filter_id']);
if (!empty($country_filter) && !empty($this->formState)) {
$input = $this->formState
->getUserInput();
$country_filter_identifier = $country_filter->options['expose']['identifier'];
if (!empty($input[$country_filter_identifier])) {
if (is_array($input[$country_filter_identifier])) {
// @todo Maybe the config validation should prevent multi-valued
// country filters. For now, we only provide administrative area
// options if a single country is selected.
if (count($input[$country_filter_identifier]) == 1) {
$this->currentCountryCode = array_shift($input[$country_filter_identifier]);
}
}
else {
$this->currentCountryCode = $input[$country_filter_identifier];
}
}
}
break;
case 'static':
if (!empty($this->formState)) {
// During filter configuration validation, we still need to know the
// current country code, but the values won't yet be saved into the
// ones accessible via FormStateInterface::getValue(). So, directly
// inspect the user input instead of the official form values.
$input = $this->formState
->getUserInput();
if (!empty($input['options']['country']['country_static_code'])) {
$form_input_country_code = $input['options']['country']['country_static_code'];
}
}
$this->currentCountryCode = !empty($form_input_country_code) ? $form_input_country_code : $this->options['country']['country_static_code'];
break;
}
// Since the country code can come from all sorts of non-validated user
// input (e.g. GET parameters) and since it might be 'All', ensure we've
// got a valid country code before we proceed. Other code in this
// filter (and especially upstream in the AddressFormatRepository and
// others) will explode if passed an invalid country code.
if (!empty($this->currentCountryCode)) {
$all_countries = $this->countryRepository
->getList();
if (empty($all_countries[$this->currentCountryCode])) {
$this->currentCountryCode = '';
}
}
return $this->currentCountryCode;
}
/**
* {@inheritdoc}
*/
public function getValueOptions() {
$this->valueOptions = [];
if ($country_code = $this
->getCurrentCountry()) {
$parents[] = $country_code;
$locale = \Drupal::languageManager()
->getConfigOverrideLanguage()
->getId();
$subdivisions = $this->subdivisionRepository
->getList($parents, $locale);
$this->valueOptions = $subdivisions;
}
return $this->valueOptions;
}
/**
* {@inheritdoc}
*/
public function buildExposedForm(&$form, FormStateInterface $form_state) {
parent::buildExposedForm($form, $form_state);
// Hide the form element if we have no options to select.
// (e.g. the country isn't set or it doesn't use administrative areas).
if (empty($this->valueOptions)) {
$identifier = $this->options['expose']['identifier'];
$form[$identifier]['#access'] = FALSE;
}
}
/**
* {@inheritdoc}
*/
public function adminSummary() {
switch ($this->options['country']['country_source']) {
case 'argument':
return $this
->t('exposed: country set via contextual filter');
case 'filter':
return $this
->t('exposed: country set via exposed filter');
case 'static':
if (!empty($this->options['exposed'])) {
return $this
->t('exposed: fixed country: @country', [
'@country' => $this->options['country']['country_static_code'],
]);
}
return $this
->t('fixed country: @country', [
'@country' => $this->options['country']['country_static_code'],
]);
}
return $this
->t('broken configuration');
}
/**
* Gets a list of countries that have administrative areas.
*
* @param array $available_countries
* The available countries to filter by.
* Defaults to the available countries for this filter.
*
* @return array
* An array of country names, keyed by country code.
*/
public function getAdministrativeAreaCountries(array $available_countries = NULL) {
if (!isset($available_countries)) {
$available_countries = $this
->getAvailableCountries();
}
$countries = [];
foreach ($available_countries as $country_code => $country_name) {
$address_format = $this->addressFormatRepository
->get($country_code);
$subdivision_depth = $address_format
->getSubdivisionDepth();
if ($subdivision_depth > 0) {
$countries[$country_code] = $country_name;
}
}
return $countries;
}
/**
* Ajax callback.
*/
public static function ajaxRefreshCountry(array $form, FormStateInterface $form_state) {
return $form['options']['value'];
}
/**
* Clears the administrative area form values when the country changes.
*
* Implemented as an #after_build callback because #after_build runs before
* validation, allowing the values to be cleared early enough to prevent the
* "Illegal choice" error.
*/
public static function clearValues(array $element, FormStateInterface $form_state) {
$triggering_element = $form_state
->getTriggeringElement();
if (!$triggering_element) {
return $element;
}
$triggering_element_name = end($triggering_element['#parents']);
if ($triggering_element_name == 'country_static_code' || $triggering_element_name == 'country_source') {
foreach ($element['#options'] as $key => $option) {
$element[$key]['#value'] = 0;
}
$element['#value'] = [];
$input =& $form_state
->getUserInput();
$input['options']['value'] = [];
}
return $element;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AdministrativeArea:: |
protected | property | The address format repository. | |
AdministrativeArea:: |
protected | property | The currently selected country (if any). | |
AdministrativeArea:: |
protected | property | If we're in the middle of building a form, its current state. | |
AdministrativeArea:: |
protected | property | The subdivision repository. | |
AdministrativeArea:: |
public | function |
Display the filter on the administrative summary Overrides InOperator:: |
|
AdministrativeArea:: |
public static | function | Ajax callback. | |
AdministrativeArea:: |
public | function |
Render our chunk of the exposed filter form when selecting Overrides FilterPluginBase:: |
|
AdministrativeArea:: |
public | function |
Options form subform for exposed filter options. Overrides InOperator:: |
|
AdministrativeArea:: |
public | function |
Provide the basic form which calls through to subforms.
If overridden, it is best to call through to the parent,
or to at least make sure all of the functions in this form
are called. Overrides FilterPluginBase:: |
|
AdministrativeArea:: |
protected | function |
Determine if a filter can be converted into a group.
Only exposed filters with operators available can be converted into groups. Overrides FilterPluginBase:: |
|
AdministrativeArea:: |
public static | function | Clears the administrative area form values when the country changes. | |
AdministrativeArea:: |
public static | function |
Creates an instance of the plugin. Overrides CountryAwareInOperatorBase:: |
|
AdministrativeArea:: |
protected | function |
Information about options for all kinds of purposes will be held here. Overrides InOperator:: |
|
AdministrativeArea:: |
public | function |
Tell the renderer about our exposed form. This only needs to be
overridden for particularly complex forms. And maybe not even then. Overrides FilterPluginBase:: |
|
AdministrativeArea:: |
public | function | Gets a list of countries that have administrative areas. | |
AdministrativeArea:: |
protected | function | Gets the current source for the country code. | |
AdministrativeArea:: |
protected | function | Gets the currently active country code. | |
AdministrativeArea:: |
public | function |
Child classes should be used to override this function and set the
'value options', unless 'options callback' is defined as a valid function
or static public method to generate these values. Overrides InOperator:: |
|
AdministrativeArea:: |
protected | function |
Shortcut to display the value form. Overrides FilterPluginBase:: |
|
AdministrativeArea:: |
public | function |
Perform any necessary changes to the form exposes prior to storage.
There is no need for this function to actually store the data. Overrides HandlerBase:: |
|
AdministrativeArea:: |
public | function |
Simple validate handler Overrides FilterPluginBase:: |
|
AdministrativeArea:: |
public | function |
Options form subform for setting options. Overrides InOperator:: |
|
AdministrativeArea:: |
protected | function |
Perform any necessary changes to the form values prior to storage.
There is no need for this function to actually store the data. Overrides InOperator:: |
|
AdministrativeArea:: |
public | function |
Constructs a new AdministrativeArea object. Overrides CountryAwareInOperatorBase:: |
|
CountryAwareInOperatorBase:: |
protected | property | The country repository. | |
CountryAwareInOperatorBase:: |
protected | property | The entity field manager. | |
CountryAwareInOperatorBase:: |
protected | property | The entity type manager. | |
CountryAwareInOperatorBase:: |
protected | function | Gets the list of available countries for the current entity field. | |
CountryAwareInOperatorBase:: |
protected | function | Gets the bundles for the current entity field. | |
CountryAwareInOperatorBase:: |
protected | function | Gets the name of the entity field on which this filter operates. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FilterPluginBase:: |
protected | property | Disable the possibility to force a single value. | 6 |
FilterPluginBase:: |
public | property | Disable the possibility to allow a exposed input to be optional. | |
FilterPluginBase:: |
public | property | Contains the information of the selected item in a grouped filter. | |
FilterPluginBase:: |
public | property | Disable the possibility to use operators. | 1 |
FilterPluginBase:: |
public | property | Contains the operator which is used on the query. | |
FilterPluginBase:: |
public | property | Contains the actual value of the field,either configured in the views ui or entered in the exposed filters. | |
FilterPluginBase:: |
public | function | Add a new group to the exposed filter groups. | |
FilterPluginBase:: |
protected static | function | Filter by no empty values, though allow the use of (string) "0". | |
FilterPluginBase:: |
protected | function | Build the form to let users create the group of exposed filters. This form is displayed when users click on button 'Build group' | |
FilterPluginBase:: |
public | function | Displays the Build Group form. | |
FilterPluginBase:: |
protected | function | Provide default options for exposed filters. | |
FilterPluginBase:: |
protected | function | Save new group items, re-enumerates and remove groups marked to delete. | |
FilterPluginBase:: |
protected | function | Validate the build group options form. | |
FilterPluginBase:: |
public | function |
Determine if a filter can be exposed. Overrides HandlerBase:: |
5 |
FilterPluginBase:: |
public | function | Can this filter be used in OR groups? | 1 |
FilterPluginBase:: |
public | function | Transform the input from a grouped filter into a standard filter. | |
FilterPluginBase:: |
protected | function | Make some translations to a form item to make it more suitable to exposing. | |
FilterPluginBase:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyInterface:: |
7 |
FilterPluginBase:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyInterface:: |
|
FilterPluginBase:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyInterface:: |
1 |
FilterPluginBase:: |
public | function | Build a form containing a group of operator | values to apply as a single filter. | |
FilterPluginBase:: |
public | function | Returns the options available for a grouped filter that users checkboxes as widget, and therefore has to be applied several times, one per item selected. | |
FilterPluginBase:: |
protected | function | Determines if the given grouped filter entry has a valid value. | 1 |
FilterPluginBase:: |
public | function |
Returns TRUE if the exposed filter works like a grouped filter. Overrides HandlerBase:: |
|
FilterPluginBase:: |
public | function |
Returns TRUE if users can select multiple groups items of a
grouped exposed filter. Overrides HandlerBase:: |
|
FilterPluginBase:: |
protected | function | Options form subform for setting the operator. | 6 |
FilterPluginBase:: |
public | function | Perform any necessary changes to the form values prior to storage. There is no need for this function to actually store the data. | |
FilterPluginBase:: |
protected | function | Validate the operator form. | |
FilterPluginBase:: |
protected | function | Sanitizes the HTML select element's options. | |
FilterPluginBase:: |
protected | function | Shortcut to display the build_group/hide button. | |
FilterPluginBase:: |
public | function | Shortcut to display the exposed options form. | |
FilterPluginBase:: |
public | function |
Shortcut to display the expose/hide button. Overrides HandlerBase:: |
|
FilterPluginBase:: |
public | function | Shortcut to display the operator form. | |
FilterPluginBase:: |
public | function |
If set to remember exposed input in the session, store it there. Overrides HandlerBase:: |
|
FilterPluginBase:: |
public | function | If set to remember exposed input in the session, store it there. This function is similar to storeExposedInput but modified to work properly when the filter is a group. | |
FilterPluginBase:: |
public | function |
Simple submit handler Overrides PluginBase:: |
|
FilterPluginBase:: |
public static | function |
Lists the trusted callbacks provided by the implementing class. Overrides PluginBase:: |
|
FilterPluginBase:: |
public | function |
Validate the options form. Overrides HandlerBase:: |
|
FilterPluginBase:: |
protected | function | Validates a filter identifier. | |
FilterPluginBase:: |
protected | function | Validate the options form. | 3 |
HandlerBase:: |
public | property | With field you can override the realField if the real field is not set. | |
HandlerBase:: |
protected | property | The module handler. | 3 |
HandlerBase:: |
public | property | Where the $query object will reside: | 7 |
HandlerBase:: |
public | property | The actual field in the database table, maybe different on other kind of query plugins/special handlers. | |
HandlerBase:: |
public | property | The relationship used for this field. | |
HandlerBase:: |
public | property | The table this handler is attached to. | |
HandlerBase:: |
public | property | The alias of the table of this handler which is used in the query. | |
HandlerBase:: |
protected | property | The views data service. | |
HandlerBase:: |
public | function |
Check whether given user has access to this handler. Overrides ViewsHandlerInterface:: |
4 |
HandlerBase:: |
public | function |
Return a string representing this handler's name in the UI. Overrides ViewsHandlerInterface:: |
4 |
HandlerBase:: |
public static | function |
Breaks x,y,z and x+y+z into an array. Overrides ViewsHandlerInterface:: |
|
HandlerBase:: |
public | function |
Determines if the handler is considered 'broken', meaning it's a
placeholder used when a handler can't be found. Overrides ViewsHandlerInterface:: |
|
HandlerBase:: |
public | function | Provide a form for setting options. | 1 |
HandlerBase:: |
public | function | Provide a form for aggregation settings. | 1 |
HandlerBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides PluginBase:: |
10 |
HandlerBase:: |
protected | function | Transform a string by a certain method. | |
HandlerBase:: |
public | function | Provide defaults for the handler. | |
HandlerBase:: |
public | function | Displays the Expose form. | |
HandlerBase:: |
public | function |
Ensure the main table for this handler is in the query. This is used
a lot. Overrides ViewsHandlerInterface:: |
2 |
HandlerBase:: |
public | function | Creates cross-database SQL dates. | 2 |
HandlerBase:: |
public | function | Creates cross-database SQL date formatting. | 2 |
HandlerBase:: |
public | function |
Determines the entity type used by this handler. Overrides ViewsHandlerInterface:: |
|
HandlerBase:: |
public | function |
Shortcut to get a handler's raw field value. Overrides ViewsHandlerInterface:: |
|
HandlerBase:: |
public | function |
Get the join object that should be used for this handler. Overrides ViewsHandlerInterface:: |
|
HandlerBase:: |
protected | function | Gets the module handler. | |
HandlerBase:: |
public static | function |
Fetches a handler to join one table to a primary table from the data cache. Overrides ViewsHandlerInterface:: |
|
HandlerBase:: |
protected | function | Gets views data service. | |
HandlerBase:: |
public | function | If a handler has 'extra options' it will get a little settings widget and another form called extra_options. | 1 |
HandlerBase:: |
public | function | Determine if this item is 'exposed', meaning it provides form elements to let users modify the view. | |
HandlerBase:: |
protected | function | Provides a unique placeholders for handlers. | |
HandlerBase:: |
public | function |
Run after the view is executed, before the result is cached. Overrides ViewsHandlerInterface:: |
|
HandlerBase:: |
public | function |
Run before the view is built. Overrides ViewsHandlerInterface:: |
2 |
HandlerBase:: |
public | function |
Sanitize the value for output. Overrides ViewsHandlerInterface:: |
|
HandlerBase:: |
public | function | Sets the module handler. | |
HandlerBase:: |
public | function |
Called just prior to query(), this lets a handler set up any relationship
it needs. Overrides ViewsHandlerInterface:: |
|
HandlerBase:: |
public | function | ||
HandlerBase:: |
public | function |
Shortcut to display the exposed options form. Overrides ViewsHandlerInterface:: |
|
HandlerBase:: |
public | function | Submit the exposed handler form | |
HandlerBase:: |
public | function | Perform any necessary changes to the form values prior to storage. There is no need for this function to actually store the data. | |
HandlerBase:: |
public | function | Calculates options stored on the handler | 1 |
HandlerBase:: |
public | function | Perform any necessary changes to the form values prior to storage. There is no need for this function to actually store the data. | 1 |
HandlerBase:: |
public | function | A submit handler that is used for storing temporary items when using multi-step changes, such as ajax requests. | |
HandlerBase:: |
public | function | Provides the handler some groupby. | 13 |
HandlerBase:: |
public | function | Validate the exposed handler form | 4 |
HandlerBase:: |
public | function | Validate the options form. | |
InOperator:: |
protected | property | 2 | |
InOperator:: |
protected | property | Stores all operations which are available on the form. | |
InOperator:: |
protected | property | The filter title. | |
InOperator:: |
public | function |
Determines if the input from a filter should change the generated query. Overrides FilterPluginBase:: |
2 |
InOperator:: |
public | function |
Provide default options for exposed filters. Overrides FilterPluginBase:: |
|
InOperator:: |
public | function |
Overrides \Drupal\views\Plugin\views\HandlerBase::init(). Overrides FilterPluginBase:: |
2 |
InOperator:: |
protected | function | ||
InOperator:: |
public | function |
Build strings from the operators() for 'select' options Overrides FilterPluginBase:: |
1 |
InOperator:: |
public | function | This kind of construct makes it relatively easy for a child class to add or remove functionality by overriding this function and adding/removing items from this array. | 1 |
InOperator:: |
protected | function | ||
InOperator:: |
protected | function | 1 | |
InOperator:: |
public | function |
Add this filter to the query. Overrides FilterPluginBase:: |
6 |
InOperator:: |
public | function | When using exposed filters, we may be required to reduce the set. | |
InOperator:: |
public | function |
Validate that the plugin is correct and can be saved. Overrides FilterPluginBase:: |
|
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
public | property | Plugins's definition | |
PluginBase:: |
public | property | The display object this plugin is for. | |
PluginBase:: |
public | property | Options for this plugin will be held here. | |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
protected | property | Stores the render API renderer. | 3 |
PluginBase:: |
protected | property | Denotes whether the plugin has an additional options form. | 8 |
PluginBase:: |
public | property | The top object of a view. | 1 |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Clears a plugin. Overrides ViewsPluginInterface:: |
2 |
PluginBase:: |
protected | function | Do the work to filter out stored options depending on the defined options. | |
PluginBase:: |
public | function |
Filter out stored options depending on the defined options. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
public | function |
Returns an array of available token replacements. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function |
Returns the plugin provider. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
protected | function | Returns the render API renderer. | 1 |
PluginBase:: |
public | function |
Adds elements for available core tokens to a form. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
public | function |
Returns a string with any core tokens replaced. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
constant | Include entity row languages when listing languages. | ||
PluginBase:: |
constant | Include negotiated languages when listing languages. | ||
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
protected | function | Makes an array of languages, optionally including special languages. | |
PluginBase:: |
public | function |
Return the human readable name of the display. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
public static | function |
Moves form elements into fieldsets for presentation purposes. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
public static | function |
Flattens the structure of form elements. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
public static | function | Returns substitutions for Views queries for languages. | |
PluginBase:: |
protected | function | Fills up the options of the plugin with defaults. | |
PluginBase:: |
public | function |
Returns the summary of the settings in the display. Overrides ViewsPluginInterface:: |
6 |
PluginBase:: |
public | function |
Provide a full list of possible theme templates used by this style. Overrides ViewsPluginInterface:: |
1 |
PluginBase:: |
public | function |
Unpack options over our existing defaults, drilling down into arrays
so that defaults don't get totally blown away. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
public | function |
Returns the usesOptions property. Overrides ViewsPluginInterface:: |
8 |
PluginBase:: |
protected | function | Replaces Views' tokens in a given string. The resulting string will be sanitized with Xss::filterAdmin. | 1 |
PluginBase:: |
constant | Query string to indicate the site default language. | ||
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
TrustedCallbackInterface:: |
constant | Untrusted callbacks throw exceptions. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger silenced E_USER_DEPRECATION errors. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger E_USER_WARNING errors. |