class FooTable in FooTable 8.2
Same name in this branch
- 8.2 src/FooTable.php \Drupal\footable\FooTable
- 8.2 src/Element/FooTable.php \Drupal\footable\Element\FooTable
- 8.2 src/Plugin/views/style/FooTable.php \Drupal\footable\Plugin\views\style\FooTable
Provides a render element for a FooTable.
Plugin annotation
@FormElement("footable");
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\Core\Render\Element\RenderElement implements ElementInterface
- class \Drupal\Core\Render\Element\FormElement implements FormElementInterface
- class \Drupal\Core\Render\Element\RenderElement implements ElementInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of FooTable
3 string references to 'FooTable'
File
- src/
Element/ FooTable.php, line 15
Namespace
Drupal\footable\ElementView source
class FooTable extends Table {
/**
* {@inheritdoc}
*/
public function getInfo() {
$info = parent::getInfo();
$class = get_class($this);
$info['#process'][] = [
$class,
'processFooTable',
];
$info['#pre_render'][] = [
$class,
'preRenderFooTable',
];
$info['#theme'] = 'footable';
foreach (static::getProperties() as $key => $property) {
$info['#' . $key] = $property['default'] ?? NULL;
}
return $info;
}
/**
* Processes a FooTable element.
*
* @param array $element
* An associative array containing the properties and children of the
* container.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
* @param array $complete_form
* The complete form structure.
*
* @return array
* The processed element.
*/
public static function processFooTable(&$element, FormStateInterface $form_state, &$complete_form) {
unset($element['#sticky'], $element['#responsive']);
return $element;
}
/**
*
*
* @param array $element
*
* @return array
*/
public static function preRenderFooTable($element) {
$element['#attributes']['class'][] = 'footable';
/* @var \Drupal\footable\FooTableInterface $footable */
$footable = Drupal::service('footable.footable');
$element['#attached']['library'][] = $footable
->getLibrary();
// Add FooTable properties.
foreach (static::getProperties() as $key => $property) {
$default = $property['default'] ?? NULL;
$value = $element['#' . $key] ?? $default;
if ($value !== $default) {
if (is_bool($value)) {
$value = $value ? 'true' : 'false';
}
$element['#attributes']['data-' . $property['key']] = $value;
}
}
if (isset($element['#header']) && is_array($element['#header'])) {
foreach ($element['#header'] as $key => &$header) {
if (!is_array($header) && Element::child($key)) {
$header = [
'data' => $header,
];
}
if ($footable = $header['footable'] ?? NULL) {
unset($header['footable']);
if (isset($footable['sort'])) {
$element['#attributes']['data-sorting'] = 'true';
$header['data-sortable'] = 'true';
$header['data-direction'] = $footable['sort'];
$header['data-breakpoints'] = 'all';
}
}
}
}
return $element;
}
/**
* Retrieve a list of available FooTable properties.
*
* @return array
* An associative array keyed by property id, containing:
* - key: The FooTable attribute key.
* - default: The default value of the property.
*/
protected static function getProperties() {
return [
'empty' => [
'key' => 'empty',
'default' => t('No Results'),
],
'expand_all' => [
'key' => 'expand-all',
'default' => FALSE,
],
'expand_first' => [
'key' => 'expand-first',
'default' => FALSE,
],
'show_header' => [
'key' => 'show-header',
'default' => FALSE,
],
'show_toggle' => [
'key' => 'show-toggle',
'default' => TRUE,
],
'toggle_column' => [
'key' => 'toggle-column',
'default' => 'first',
],
'use_parent_width' => [
'key' => 'use-parent-width',
'default' => FALSE,
],
// Filtering.
'filtering' => [
'key' => 'filtering',
'default' => FALSE,
],
'filter_container' => [
'key' => 'filter-form-container',
],
'filter_delay' => [
'key' => 'filter-delay',
'default' => 1200,
],
'filter_dropdown_title' => [
'key' => 'filter-dropdown-title',
],
'filter_exact_match' => [
'key' => 'filter-exact-match',
'default' => FALSE,
],
'filter_focus' => [
'key' => 'filter-focus',
'default' => TRUE,
],
'filter_ignore_case' => [
'key' => 'filter-ignore-case',
'default' => TRUE,
],
'filter_min' => [
'key' => 'filter-min',
'default' => 1,
],
'filter_placeholder' => [
'key' => 'filter-placeholder',
'default' => t('Search'),
],
'filter_position' => [
'key' => 'filter-position',
'default' => 'right',
],
'filter_space' => [
'key' => 'filter-space',
'default' => 'AND',
],
// Sorting.
'sorting' => [
'key' => 'sorting',
'default' => FALSE,
],
// Paging.
'paging' => [
'key' => 'paging',
'default' => FALSE,
],
'paging_container' => [
'key' => 'paging-container',
],
'paging_count_format' => [
'key' => 'paging-container',
'default' => '{CP} of {TP}',
],
'paging_current' => [
'key' => 'paging-current',
'default' => 1,
],
'paging_limit' => [
'key' => 'paging-limit',
'default' => 5,
],
'paging_position' => [
'key' => 'paging-position',
'default' => 'center',
],
'paging_size' => [
'key' => 'paging-size',
'default' => 10,
],
// State.
'state' => [
'key' => 'state',
'default' => FALSE,
],
'state_filtering' => [
'key' => 'state-filtering',
'default' => TRUE,
],
'state_paging' => [
'key' => 'state-paging',
'default' => TRUE,
],
'state_sorting' => [
'key' => 'state-sorting',
'default' => TRUE,
],
'state_key' => [
'key' => 'state-key',
],
];
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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 | |
FooTable:: |
public | function |
Returns the element properties for this element. Overrides Table:: |
|
FooTable:: |
protected static | function | Retrieve a list of available FooTable properties. | |
FooTable:: |
public static | function | ||
FooTable:: |
public static | function | Processes a FooTable element. | |
FormElement:: |
public static | function | Adds autocomplete functionality to elements. | |
FormElement:: |
public static | function | #process callback for #pattern form element property. | |
FormElement:: |
public static | function | #element_validate callback for #pattern form element property. | |
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. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |
RenderElement:: |
public static | function | Adds Ajax information about an element to communicate with JavaScript. | |
RenderElement:: |
public static | function | Adds members of this group as actual elements for rendering. | |
RenderElement:: |
public static | function | Form element processing handler for the #ajax form property. | 1 |
RenderElement:: |
public static | function | Arranges elements into groups. | |
RenderElement:: |
public static | function |
Sets a form element's class attribute. Overrides ElementInterface:: |
|
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. | |
Table:: |
public static | function | #pre_render callback to transform children of an element of #type 'table'. | |
Table:: |
public static | function | #process callback for #type 'table' to add tableselect support. | |
Table:: |
public static | function | #element_validate callback for #type 'table'. | |
Table:: |
public static | function |
Determines how user input is mapped to an element's #value property. Overrides FormElement:: |
1 |