Skip to content
Snippets Groups Projects
Verified Commit 1a0bd14c authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3491515 by quietone, akulsaxena: Fix...

Issue #3491515 by quietone, akulsaxena: Fix Drupal.Commenting.FunctionComment.Missing in views plugins, pt 2
parent 95579a70
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,9 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, ?array &$ ...@@ -31,6 +31,9 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, ?array &$
$this->setItemsPerPage(0); $this->setItemsPerPage(0);
} }
/**
* {@inheritdoc}
*/
public function summaryTitle() { public function summaryTitle() {
if (!empty($this->options['offset'])) { if (!empty($this->options['offset'])) {
return $this->t('All items, skip @skip', ['@skip' => $this->options['offset']]); return $this->t('All items, skip @skip', ['@skip' => $this->options['offset']]);
...@@ -38,6 +41,9 @@ public function summaryTitle() { ...@@ -38,6 +41,9 @@ public function summaryTitle() {
return $this->t('All items'); return $this->t('All items');
} }
/**
* {@inheritdoc}
*/
protected function defineOptions() { protected function defineOptions() {
$options = parent::defineOptions(); $options = parent::defineOptions();
$options['offset'] = ['default' => 0]; $options['offset'] = ['default' => 0];
...@@ -59,26 +65,44 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ...@@ -59,26 +65,44 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
]; ];
} }
/**
* {@inheritdoc}
*/
public function usePager() { public function usePager() {
return FALSE; return FALSE;
} }
/**
* {@inheritdoc}
*/
public function useCountQuery() { public function useCountQuery() {
return FALSE; return FALSE;
} }
/**
* {@inheritdoc}
*/
public function getItemsPerPage() { public function getItemsPerPage() {
return 0; return 0;
} }
/**
* {@inheritdoc}
*/
public function executeCountQuery(&$count_query) { public function executeCountQuery(&$count_query) {
// If we are displaying all items, never count. But we can update the count in post_execute. // If we are displaying all items, never count. But we can update the count in post_execute.
} }
/**
* {@inheritdoc}
*/
public function postExecute(&$result) { public function postExecute(&$result) {
$this->total_items = count($result); $this->total_items = count($result);
} }
/**
* {@inheritdoc}
*/
public function query() { public function query() {
// The only query modifications we might do are offsets. // The only query modifications we might do are offsets.
if (!empty($this->options['offset'])) { if (!empty($this->options['offset'])) {
......
...@@ -252,20 +252,38 @@ public function hasMoreRecords() { ...@@ -252,20 +252,38 @@ public function hasMoreRecords() {
&& $this->total_items > (intval($this->current_page) + 1) * $this->getItemsPerPage(); && $this->total_items > (intval($this->current_page) + 1) * $this->getItemsPerPage();
} }
/**
* Allows the exposed form to be altered.
*/
public function exposedFormAlter(&$form, FormStateInterface $form_state) {} public function exposedFormAlter(&$form, FormStateInterface $form_state) {}
/**
* Allows the exposed form to be validated.
*/
public function exposedFormValidate(&$form, FormStateInterface $form_state) {} public function exposedFormValidate(&$form, FormStateInterface $form_state) {}
/**
* Handles submission of the exposed form.
*/
public function exposedFormSubmit(&$form, FormStateInterface $form_state, &$exclude) {} public function exposedFormSubmit(&$form, FormStateInterface $form_state, &$exclude) {}
/**
* Indicates whether this pager uses exposed filters.
*/
public function usesExposed() { public function usesExposed() {
return FALSE; return FALSE;
} }
/**
* Returns whether the items per page is exposed.
*/
protected function itemsPerPageExposed() { protected function itemsPerPageExposed() {
return FALSE; return FALSE;
} }
/**
* Returns whether the offset is exposed.
*/
protected function isOffsetExposed() { protected function isOffsetExposed() {
return FALSE; return FALSE;
} }
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
)] )]
class Some extends PagerPluginBase { class Some extends PagerPluginBase {
/**
* {@inheritdoc}
*/
public function summaryTitle() { public function summaryTitle() {
if (!empty($this->options['offset'])) { if (!empty($this->options['offset'])) {
return $this->formatPlural($this->options['items_per_page'], '@count item, skip @skip', '@count items, skip @skip', ['@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']]); return $this->formatPlural($this->options['items_per_page'], '@count item, skip @skip', '@count items, skip @skip', ['@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']]);
...@@ -26,6 +29,9 @@ public function summaryTitle() { ...@@ -26,6 +29,9 @@ public function summaryTitle() {
return $this->formatPlural($this->options['items_per_page'], '@count item', '@count items', ['@count' => $this->options['items_per_page']]); return $this->formatPlural($this->options['items_per_page'], '@count item', '@count items', ['@count' => $this->options['items_per_page']]);
} }
/**
* {@inheritdoc}
*/
protected function defineOptions() { protected function defineOptions() {
$options = parent::defineOptions(); $options = parent::defineOptions();
$options['items_per_page'] = ['default' => 10]; $options['items_per_page'] = ['default' => 10];
...@@ -57,14 +63,23 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ...@@ -57,14 +63,23 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
]; ];
} }
/**
* {@inheritdoc}
*/
public function usePager() { public function usePager() {
return FALSE; return FALSE;
} }
/**
* {@inheritdoc}
*/
public function useCountQuery() { public function useCountQuery() {
return FALSE; return FALSE;
} }
/**
* {@inheritdoc}
*/
public function query() { public function query() {
$this->view->query->setLimit($this->options['items_per_page']); $this->view->query->setLimit($this->options['items_per_page']);
$this->view->query->setOffset($this->options['offset']); $this->view->query->setOffset($this->options['offset']);
......
...@@ -62,6 +62,9 @@ public static function create(ContainerInterface $container, array $configuratio ...@@ -62,6 +62,9 @@ public static function create(ContainerInterface $container, array $configuratio
); );
} }
/**
* {@inheritdoc}
*/
protected function defineOptions() { protected function defineOptions() {
$options = parent::defineOptions(); $options = parent::defineOptions();
$options['items_per_page'] = ['default' => 10]; $options['items_per_page'] = ['default' => 10];
...@@ -232,6 +235,9 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ...@@ -232,6 +235,9 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
]; ];
} }
/**
* {@inheritdoc}
*/
public function validateOptionsForm(&$form, FormStateInterface $form_state) { public function validateOptionsForm(&$form, FormStateInterface $form_state) {
// Only accept integer values. // Only accept integer values.
$error = FALSE; $error = FALSE;
...@@ -265,6 +271,9 @@ public function validateOptionsForm(&$form, FormStateInterface $form_state) { ...@@ -265,6 +271,9 @@ public function validateOptionsForm(&$form, FormStateInterface $form_state) {
} }
} }
/**
* {@inheritdoc}
*/
public function query() { public function query() {
if ($this->itemsPerPageExposed()) { if ($this->itemsPerPageExposed()) {
$query = $this->view->getRequest()->query; $query = $this->view->getRequest()->query;
...@@ -313,6 +322,9 @@ public function setCurrentPage($number = NULL) { ...@@ -313,6 +322,9 @@ public function setCurrentPage($number = NULL) {
$this->current_page = max(0, $this->pagerParameters->findPage($this->options['id'])); $this->current_page = max(0, $this->pagerParameters->findPage($this->options['id']));
} }
/**
* Gets the total number of pages.
*/
public function getPagerTotal() { public function getPagerTotal() {
if ($items_per_page = intval($this->getItemsPerPage())) { if ($items_per_page = intval($this->getItemsPerPage())) {
return ceil($this->total_items / $items_per_page); return ceil($this->total_items / $items_per_page);
...@@ -347,18 +359,30 @@ public function updatePageInfo() { ...@@ -347,18 +359,30 @@ public function updatePageInfo() {
} }
} }
/**
* {@inheritdoc}
*/
public function usesExposed() { public function usesExposed() {
return $this->itemsPerPageExposed() || $this->isOffsetExposed(); return $this->itemsPerPageExposed() || $this->isOffsetExposed();
} }
/**
* {@inheritdoc}
*/
protected function itemsPerPageExposed() { protected function itemsPerPageExposed() {
return !empty($this->options['expose']['items_per_page']); return !empty($this->options['expose']['items_per_page']);
} }
/**
* {@inheritdoc}
*/
protected function isOffsetExposed() { protected function isOffsetExposed() {
return !empty($this->options['expose']['offset']); return !empty($this->options['expose']['offset']);
} }
/**
* {@inheritdoc}
*/
public function exposedFormAlter(&$form, FormStateInterface $form_state) { public function exposedFormAlter(&$form, FormStateInterface $form_state) {
if ($this->itemsPerPageExposed()) { if ($this->itemsPerPageExposed()) {
$options = explode(',', $this->options['expose']['items_per_page_options']); $options = explode(',', $this->options['expose']['items_per_page_options']);
...@@ -390,6 +414,9 @@ public function exposedFormAlter(&$form, FormStateInterface $form_state) { ...@@ -390,6 +414,9 @@ public function exposedFormAlter(&$form, FormStateInterface $form_state) {
} }
} }
/**
* {@inheritdoc}
*/
public function exposedFormValidate(&$form, FormStateInterface $form_state) { public function exposedFormValidate(&$form, FormStateInterface $form_state) {
if (!$form_state->isValueEmpty('offset') && trim($form_state->getValue('offset'))) { if (!$form_state->isValueEmpty('offset') && trim($form_state->getValue('offset'))) {
if (!is_numeric($form_state->getValue('offset')) || $form_state->getValue('offset') < 0) { if (!is_numeric($form_state->getValue('offset')) || $form_state->getValue('offset') < 0) {
......
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
)] )]
class DefaultSummary extends StylePluginBase { class DefaultSummary extends StylePluginBase {
/**
* {@inheritdoc}
*/
protected function defineOptions() { protected function defineOptions() {
$options = parent::defineOptions(); $options = parent::defineOptions();
...@@ -31,12 +34,18 @@ protected function defineOptions() { ...@@ -31,12 +34,18 @@ protected function defineOptions() {
return $options; return $options;
} }
/**
* {@inheritdoc}
*/
public function query() { public function query() {
if (!empty($this->options['override'])) { if (!empty($this->options['override'])) {
$this->view->setItemsPerPage(intval($this->options['items_per_page'])); $this->view->setItemsPerPage(intval($this->options['items_per_page']));
} }
} }
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) { public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['base_path'] = [ $form['base_path'] = [
'#type' => 'textfield', '#type' => 'textfield',
...@@ -71,6 +80,9 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ...@@ -71,6 +80,9 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
]; ];
} }
/**
* {@inheritdoc}
*/
public function render() { public function render() {
$rows = []; $rows = [];
foreach ($this->view->result as $row) { foreach ($this->view->result as $row) {
......
...@@ -37,6 +37,9 @@ class Rss extends StylePluginBase { ...@@ -37,6 +37,9 @@ class Rss extends StylePluginBase {
*/ */
protected $usesRowPlugin = TRUE; protected $usesRowPlugin = TRUE;
/**
* Attaches the RSS icon and feed link to the view.
*/
public function attachTo(array &$build, $display_id, Url $feed_url, $title) { public function attachTo(array &$build, $display_id, Url $feed_url, $title) {
$url_options = []; $url_options = [];
$input = $this->view->getExposedInput(); $input = $this->view->getExposedInput();
...@@ -63,6 +66,9 @@ public function attachTo(array &$build, $display_id, Url $feed_url, $title) { ...@@ -63,6 +66,9 @@ public function attachTo(array &$build, $display_id, Url $feed_url, $title) {
]; ];
} }
/**
* {@inheritdoc}
*/
protected function defineOptions() { protected function defineOptions() {
$options = parent::defineOptions(); $options = parent::defineOptions();
...@@ -71,6 +77,9 @@ protected function defineOptions() { ...@@ -71,6 +77,9 @@ protected function defineOptions() {
return $options; return $options;
} }
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) { public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state); parent::buildOptionsForm($form, $form_state);
...@@ -108,6 +117,9 @@ public function getDescription() { ...@@ -108,6 +117,9 @@ public function getDescription() {
return $description; return $description;
} }
/**
* {@inheritdoc}
*/
public function render() { public function render() {
$rows = []; $rows = [];
......
...@@ -64,6 +64,9 @@ class Table extends StylePluginBase implements CacheableDependencyInterface { ...@@ -64,6 +64,9 @@ class Table extends StylePluginBase implements CacheableDependencyInterface {
*/ */
public $order; public $order;
/**
* {@inheritdoc}
*/
protected function defineOptions() { protected function defineOptions() {
$options = parent::defineOptions(); $options = parent::defineOptions();
...@@ -413,10 +416,16 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ...@@ -413,10 +416,16 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
]; ];
} }
/**
* {@inheritdoc}
*/
public function evenEmpty() { public function evenEmpty() {
return parent::evenEmpty() || !empty($this->options['empty_table']); return parent::evenEmpty() || !empty($this->options['empty_table']);
} }
/**
* {@inheritdoc}
*/
public function wizardSubmit(&$form, FormStateInterface $form_state, WizardInterface $wizard, &$display_options, $display_type) { public function wizardSubmit(&$form, FormStateInterface $form_state, WizardInterface $wizard, &$display_options, $display_type) {
// If any of the displays use the table style, make sure that the fields // If any of the displays use the table style, make sure that the fields
// always have a labels by unsetting the override. // always have a labels by unsetting the override.
......
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
)] )]
class UnformattedSummary extends DefaultSummary { class UnformattedSummary extends DefaultSummary {
/**
* {@inheritdoc}
*/
protected function defineOptions() { protected function defineOptions() {
$options = parent::defineOptions(); $options = parent::defineOptions();
$options['inline'] = ['default' => FALSE]; $options['inline'] = ['default' => FALSE];
...@@ -27,6 +30,9 @@ protected function defineOptions() { ...@@ -27,6 +30,9 @@ protected function defineOptions() {
return $options; return $options;
} }
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) { public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state); parent::buildOptionsForm($form, $form_state);
$form['inline'] = [ $form['inline'] = [
......
...@@ -78,6 +78,8 @@ ...@@ -78,6 +78,8 @@
<include-pattern>core/modules/*/Plugin/views/display/*</include-pattern> <include-pattern>core/modules/*/Plugin/views/display/*</include-pattern>
<include-pattern>core/modules/*/Plugin/views/exposed_form/*</include-pattern> <include-pattern>core/modules/*/Plugin/views/exposed_form/*</include-pattern>
<include-pattern>core/modules/*/Plugin/views/field/*</include-pattern> <include-pattern>core/modules/*/Plugin/views/field/*</include-pattern>
<include-pattern>core/modules/*/Plugin/views/pager/*</include-pattern>
<include-pattern>core/modules/*/Plugin/views/style/*</include-pattern>
<include-pattern>*/Database/*</include-pattern> <include-pattern>*/Database/*</include-pattern>
<exclude-pattern>*/tests/*</exclude-pattern> <exclude-pattern>*/tests/*</exclude-pattern>
</rule> </rule>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment