class BootstrapAccordion in Bootstrap Quick Tabs 8
Provides a 'Bootstrap Accordion' tab renderer.
Plugin annotation
@TabRenderer(
id = "bootstrap_accordion",
name = @Translation("bootstrap accordion"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\quicktabs\TabRendererBase implements TabRendererInterface
- class \Drupal\bootstrap_quicktabs\Plugin\TabRenderer\BootstrapAccordion uses StringTranslationTrait
- class \Drupal\quicktabs\TabRendererBase implements TabRendererInterface
Expanded class hierarchy of BootstrapAccordion
File
- src/
Plugin/ TabRenderer/ BootstrapAccordion.php, line 18
Namespace
Drupal\bootstrap_quicktabs\Plugin\TabRendererView source
class BootstrapAccordion extends TabRendererBase {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function render(QuickTabsInstance $instance) {
$qt_id = $instance
->id();
$type = \Drupal::service('plugin.manager.tab_type');
// The render array used to build the block.
$build = [];
// Add a wrapper.
$build['#theme_wrappers'] = [
'container' => [
'#attributes' => [
'class' => [
'panel-group',
],
'id' => 'panel-group-' . $qt_id,
],
],
];
$panels = [];
foreach ($instance
->getConfigurationData() as $index => $tab) {
$qsid = 'quickset-' . $qt_id;
$object = $type
->createInstance($tab['type']);
$render = $object
->render($tab);
$panel_id = $qsid . '-' . $index;
// If user wants to hide empty tabs and there is no content
// then skip to next tab.
if ($instance
->getHideEmptyTabs() && empty($render)) {
continue;
}
$active_tab = $instance
->getDefaultTab() == 9999 ? 0 : $instance
->getDefaultTab();
$panel_class = '';
if ($active_tab == $index) {
$panel_class = 'in';
}
if (!empty($tab['content'][$tab['type']]['options']['display_title']) && !empty($tab['content'][$tab['type']]['options']['block_title'])) {
$build['pages'][$index]['#title'] = $tab['content'][$tab['type']]['options']['block_title'];
}
$panel = [
'id' => $panel_id,
'classes' => $panel_class,
'title' => new TranslatableMarkup($tab['title']),
'content' => render($render),
];
$panels["{$panel_id}"] = $panel;
}
$build['#theme'] = 'bootstrap_accordion';
$build['#panels'] = $panels;
$build['#id'] = $qt_id;
return $build;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BootstrapAccordion:: |
public | function |
Return a render array for the whole Quick Tabs instance. Overrides TabRendererBase:: |
|
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 |
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. | |
TabRendererBase:: |
public | function | Gets the name of the plugin. | |
TabRendererBase:: |
public | function |
Return form elements used on the edit/add from. Overrides TabRendererInterface:: |
2 |