class BatStateWidget in Booking and Availability Management Tools for Drupal 8
Plugin annotation
@FacetsWidget(
id = "bat_state",
label = @Translation("BAT State"),
description = @Translation("A configurable widget for BAT"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\facets\Widget\WidgetPluginBase implements WidgetPluginInterface
- class \Drupal\facets\Plugin\facets\widget\LinksWidget
- class \Drupal\bat_facets\Plugin\facets\widget\BatStateWidget
- class \Drupal\facets\Plugin\facets\widget\LinksWidget
- class \Drupal\facets\Widget\WidgetPluginBase implements WidgetPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of BatStateWidget
File
- modules/
bat_facets/ src/ Plugin/ facets/ widget/ BatStateWidget.php, line 22 - Contains \Drupal\bat_facets\Plugin\facets\widget\BatStateWidget.
Namespace
Drupal\bat_facets\Plugin\facets\widgetView source
class BatStateWidget extends LinksWidget {
/**
* The form builder.
*
* @var \Drupal\Core\Form\FormBuilder
*/
protected $formBuilder;
/**
* {@inheritdoc}
*/
public function build(FacetInterface $facet) {
$build = $this->formBuilder
->getForm('Drupal\\bat_facets\\Form\\FacetsAvailabilityForm');
return $build;
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state, FacetInterface $facet) {
$event_types_options = [];
$event_types = bat_event_get_types();
foreach ($event_types as $event_type) {
$event_types_options[$event_type
->id()] = $event_type
->label();
}
if (isset($this
->getConfiguration()['event_type'])) {
$ev_type = $this
->getConfiguration()['event_type'];
}
else {
$ev_types = array_keys($event_types_options);
$ev_type = reset($ev_types);
}
$form['event_type'] = [
'#type' => 'select',
'#title' => t('Event type'),
'#options' => $event_types_options,
'#default_value' => $ev_type,
'#ajax' => [
'callback' => '::buildAjaxWidgetConfigForm',
'wrapper' => 'facets-widget-config-form',
],
];
if ($event_types[$ev_type]
->getFixedEventStates()) {
$state_options = bat_unit_state_options($ev_type);
$form['state'] = [
'#type' => 'select',
'#title' => t('Event State'),
'#options' => $state_options,
'#multiple' => TRUE,
'#default_value' => isset($this
->getConfiguration()['state']) ? $this
->getConfiguration()['state'] : '',
];
}
else {
$form['first_state'] = [
'#type' => 'textfield',
'#title' => t('First state'),
'#size' => 10,
'#prefix' => '<div class="container-inline">',
'#default_value' => isset($this
->getConfiguration()['first_state']) ? $this
->getConfiguration()['first_state'] : '',
];
$form['second_state'] = [
'#type' => 'textfield',
'#title' => t('Second state'),
'#size' => 10,
'#suffix' => '</div>',
'#default_value' => isset($this
->getConfiguration()['second_state']) ? $this
->getConfiguration()['second_state'] : '',
];
}
return $form;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BatStateWidget:: |
protected | property | The form builder. | |
BatStateWidget:: |
public | function |
Builds the facet widget for rendering. Overrides LinksWidget:: |
|
BatStateWidget:: |
public | function |
Provides a configuration form for this widget. Overrides LinksWidget:: |
|
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 | |
LinksWidget:: |
protected | function | Appends widget library and relevant information for it to build array. | 1 |
LinksWidget:: |
public | function |
Gets default configuration for this plugin. Overrides WidgetPluginBase:: |
|
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:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
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 | Determines if the plugin is configurable. | |
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. | |
WidgetPluginBase:: |
protected | property | The facet the widget is being built for. | |
WidgetPluginBase:: |
protected | property | Show the amount of results next to the result. | |
WidgetPluginBase:: |
protected | function | Builds a renderable array of result items. | 1 |
WidgetPluginBase:: |
protected | function | Builds a facet result item. | |
WidgetPluginBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
WidgetPluginBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
WidgetPluginBase:: |
protected | function | Provides a full array of possible theme functions to try for a given hook. | |
WidgetPluginBase:: |
public | function |
Picks the preferred query type for this widget. Overrides WidgetPluginInterface:: |
3 |
WidgetPluginBase:: |
public | function |
Checks is a specific property is required for this widget. Overrides WidgetPluginInterface:: |
2 |
WidgetPluginBase:: |
protected | function | Returns the text or link for an item. | |
WidgetPluginBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
WidgetPluginBase:: |
public | function |
Checks if the facet is supported by this processor. Overrides WidgetPluginInterface:: |
1 |
WidgetPluginBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |