Mini.php in Drupal 8
File
core/modules/views/src/Plugin/views/pager/Mini.php
View source
<?php
namespace Drupal\views\Plugin\views\pager;
class Mini extends SqlBase {
public function defineOptions() {
$options = parent::defineOptions();
$options['tags']['contains']['previous']['default'] = '‹‹';
$options['tags']['contains']['next']['default'] = '››';
return $options;
}
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'],
]);
}
public function query() {
parent::query();
if (!$this->view->get_total_rows) {
if ($this
->getItemsPerPage() > 0 && (empty($this->options['total_pages']) || $this
->getCurrentPage() < $this->options['total_pages'])) {
$limit = $this->view->query
->getLimit();
$limit += 1;
$this->view->query
->setLimit($limit);
}
}
}
public function useCountQuery() {
return FALSE;
}
public function postExecute(&$result) {
if (!$this->view->get_total_rows) {
$this->total_items = $this
->getCurrentPage() * $this
->getItemsPerPage() + count($result);
if ($this
->getItemsPerPage() > 0 && count($result) > $this
->getItemsPerPage()) {
array_pop($result);
}
}
}
public function render($input) {
$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>',
];
}
}
Classes
Name |
Description |
Mini |
The plugin to handle mini pager. |