class Mini
Same name and namespace in other branches
- 11.x core/modules/views/src/Plugin/views/pager/Mini.php \Drupal\views\Plugin\views\pager\Mini
The plugin to handle mini pager.
Plugin annotation
@ViewsPager(
id = "mini",
title = @Translation("Paged output, mini pager"),
short_title = @Translation("Mini"),
help = @Translation("A simple pager containing previous and next links."),
theme = "views_mini_pager"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait implements \Drupal\Component\Plugin\PluginBase
- class \Drupal\views\Plugin\views\PluginBase extends \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface implements \Drupal\Core\Plugin\PluginBase
- class \Drupal\views\Plugin\views\pager\PagerPluginBase implements \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\pager\SqlBase extends \Drupal\Core\Cache\CacheableDependencyInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface implements \Drupal\views\Plugin\views\pager\PagerPluginBase
- class \Drupal\views\Plugin\views\pager\Mini implements \Drupal\views\Plugin\views\pager\SqlBase
- class \Drupal\views\Plugin\views\pager\SqlBase extends \Drupal\Core\Cache\CacheableDependencyInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface implements \Drupal\views\Plugin\views\pager\PagerPluginBase
- class \Drupal\views\Plugin\views\pager\PagerPluginBase implements \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\PluginBase extends \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface implements \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait implements \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of Mini
Related topics
50 string references to 'Mini'
- AreaDisplayLinkTest::setUp in core/
modules/ views/ tests/ src/ Kernel/ Handler/ AreaDisplayLinkTest.php - DisplayPluginBase::defineOptions in core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php - FieldCounterTest::testPager in core/
modules/ views/ tests/ src/ Kernel/ Handler/ FieldCounterTest.php - Tests the counter field when using a pager.
- PagerTest::testStorePagerSettings in core/
modules/ views/ tests/ src/ Functional/ Plugin/ PagerTest.php - Pagers was sometimes not stored.
- PagerTest::testStorePagerSettings in core/
modules/ views/ tests/ src/ Functional/ Plugin/ PagerTest.php - Pagers was sometimes not stored.
File
-
core/
modules/ views/ src/ Plugin/ views/ pager/ Mini.php, line 18
Namespace
Drupal\views\Plugin\views\pagerView source
class Mini extends SqlBase {
/**
* Overrides \Drupal\views\Plugin\views\pager\PagerPlugin::defineOptions().
*
* Provides sane defaults for the next/previous links.
*/
public function defineOptions() {
$options = parent::defineOptions();
$options['tags']['contains']['previous']['default'] = '‹‹';
$options['tags']['contains']['next']['default'] = '››';
return $options;
}
/**
* {@inheritdoc}
*/
public function summaryTitle() {
if (!empty($this->options['offset'])) {
return $this->formatPlural($this->options['items_per_page'], 'Mini pager, @count item, skip @skip', 'Mini pager, @count items, skip @skip', [
'@count' => $this->options['items_per_page'],
'@skip' => $this->options['offset'],
]);
}
return $this->formatPlural($this->options['items_per_page'], 'Mini pager, @count item', 'Mini pager, @count items', [
'@count' => $this->options['items_per_page'],
]);
}
/**
* {@inheritdoc}
*/
public function query() {
parent::query();
// Only modify the query if we don't want to do a total row count
if (!$this->view->get_total_rows) {
// Don't query for the next page if we have a pager that has a limited
// amount of pages.
if ($this->getItemsPerPage() > 0 && (empty($this->options['total_pages']) || $this->getCurrentPage() < $this->options['total_pages'])) {
// Increase the items in the query in order to be able to find out
// whether there is another page.
$limit = $this->view->query
->getLimit();
$limit += 1;
$this->view->query
->setLimit($limit);
}
}
}
/**
* {@inheritdoc}
*/
public function useCountQuery() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function postExecute(&$result) {
// Only modify the result if we didn't do a total row count
if (!$this->view->get_total_rows) {
$this->total_items = $this->getCurrentPage() * $this->getItemsPerPage() + count($result);
// query() checks if we need a next link by setting limit 1 record past
// this page If we got the extra record we need to remove it before we
// render the result.
if ($this->getItemsPerPage() > 0 && count($result) > $this->getItemsPerPage()) {
array_pop($result);
}
}
}
/**
* {@inheritdoc}
*/
public function render($input) {
// The 1, 3 indexes are correct, see template_preprocess_pager().
$tags = [
1 => $this->options['tags']['previous'],
3 => $this->options['tags']['next'],
];
return [
'#theme' => $this->themeFunctions(),
'#tags' => $tags,
'#element' => $this->options['id'],
'#parameters' => $input,
'#route_name' => !empty($this->view->live_preview) ? '<current>' : '<none>',
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.