You are here

class Scrollpane in Pagerer 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/pagerer/Scrollpane.php \Drupal\pagerer\Plugin\pagerer\Scrollpane

Pager style to display a scrollpane embedding a full pager.

Page navigation is managed via a javascript.

Plugin annotation


@PagererStyle(
  id = "scrollpane",
  title = @Translation("Scrollpane pager"),
  short_title = @Translation("Scrollpane"),
  help = @Translation("Pager style to display a scrollpane embedding a full pager."),
  style_type = "base"
)

Hierarchy

Expanded class hierarchy of Scrollpane

File

src/Plugin/pagerer/Scrollpane.php, line 20

Namespace

Drupal\pagerer\Plugin\pagerer
View source
class Scrollpane extends PagererStyleBase {

  /**
   * {@inheritdoc}
   */
  protected function buildEmptyPager() {

    // The text will be embedded in the scrollpane.
    return $this
      ->buildPagerItems();
  }

  /**
   * Return the pager render array.
   *
   * @return array
   *   render array.
   */
  protected function buildPagerItems() {

    // Prepares state.
    $state_settings = [
      'quantity' => $this
        ->getOption('quantity'),
      'pageTag' => [
        'page_title' => $this
          ->getTag($this
          ->getOption('display') . '.page_title'),
        'first_title' => $this
          ->getTag($this
          ->getOption('display') . '.first_title'),
        'last_title' => $this
          ->getTag($this
          ->getOption('display') . '.last_title'),
      ],
    ];
    $pagerer_widget_id = $this
      ->prepareJsState($state_settings);
    $items = [];

    // Left buttons.
    $vars = $this
      ->getNavigationItem('first', FALSE);
    $items[] = [
      'widget' => [
        '#theme' => 'pagerer_scrollpane_button',
        '#scope' => 'first',
        '#text' => $vars['text'],
        '#title' => $vars['title'],
      ],
    ];
    $vars = $this
      ->getNavigationItem('previous', FALSE);
    $items[] = [
      'widget' => [
        '#theme' => 'pagerer_scrollpane_button',
        '#scope' => 'previous',
        '#text' => $vars['text'],
        '#title' => $vars['title'],
      ],
    ];

    // Scrollpane.
    $embed_pager_config = NestedArray::mergeDeep($this->configuration, [
      'prefix_display' => FALSE,
      'display_mode' => 'normal',
      'suffix_display' => FALSE,
      'first_link' => 'never',
      'previous_link' => 'never',
      'next_link' => 'never',
      'last_link' => 'never',
      'fl_breakers' => FALSE,
    ]);
    $items[] = [
      'widget' => [
        '#id' => $pagerer_widget_id,
        '#type' => 'pager',
        '#theme' => 'pagerer_base',
        '#style' => 'standard',
        '#element' => $this->pager
          ->getElement(),
        '#parameters' => $this->parameters,
        '#route_name' => $this->pager
          ->getRouteName(),
        '#route_parameters' => $this->pager
          ->getRouteParameters(),
        '#config' => $embed_pager_config,
        '#embedded' => TRUE,
        '#state' => $state_settings,
      ],
    ];

    // Right buttons.
    $vars = $this
      ->getNavigationItem('next', FALSE);
    $items[] = [
      'widget' => [
        '#theme' => 'pagerer_scrollpane_button',
        '#scope' => 'next',
        '#text' => $vars['text'],
        '#title' => $vars['title'],
      ],
    ];
    $vars = $this
      ->getNavigationItem('last', FALSE);
    $items[] = [
      'widget' => [
        '#theme' => 'pagerer_scrollpane_button',
        '#scope' => 'last',
        '#text' => $vars['text'],
        '#title' => $vars['title'],
      ],
    ];
    return $items;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PagererStyleBase::$configFactory protected property The config factory.
PagererStyleBase::$pager protected property The Pagerer pager object.
PagererStyleBase::$pagererPreset protected property The PagererPreset object being configured.
PagererStyleBase::$pagererPresetPane protected property The PagererPreset pane being configured.
PagererStyleBase::$parameters protected property Query parameters as requested by the theme call.
PagererStyleBase::$typedConfigManager protected property The config type plugins manager.
PagererStyleBase::buildConfigurationForm public function Form constructor. Overrides PluginFormInterface::buildConfigurationForm 4
PagererStyleBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
PagererStyleBase::getDisplayTag protected function Returns a translated textual element for pages/items/item ranges.
PagererStyleBase::getNavigationItem protected function Gets a link/button item to first/previous/next/last link.
PagererStyleBase::getOption protected function Returns a configuration element.
PagererStyleBase::getPageItem protected function Gets a 'page' item in the pager.
PagererStyleBase::getTag protected function Returns a translated textual element from the configuration.
PagererStyleBase::prepareJsState protected function Prepares input parameters for a JS enabled pager widget.
PagererStyleBase::preprocess public function Prepares to render the pager. Overrides PagererStyleInterface::preprocess
PagererStyleBase::setConfigurationContext public function Sets the current PagererPreset and pane being configured.
PagererStyleBase::setPager public function Sets the Pagerer pager to be rendered. Overrides PagererStyleInterface::setPager
PagererStyleBase::submitConfigurationForm public function Form submission handler. Overrides PluginFormInterface::submitConfigurationForm
PagererStyleBase::validateConfigurationForm public function Form validation handler. Overrides PluginFormInterface::validateConfigurationForm
PagererStyleBase::__construct public function Constructs a \Drupal\pagerer\Plugin\pagerer\PagererStyleBase object. Overrides PluginBase::__construct
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
Scrollpane::buildEmptyPager protected function Render a 'no pages to display' text. Overrides PagererStyleBase::buildEmptyPager
Scrollpane::buildPagerItems protected function Return the pager render array.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.