summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/views/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/views/src')
-rw-r--r--core/modules/views/src/Entity/View.php2
-rw-r--r--core/modules/views/src/FieldViewsDataProvider.php31
-rw-r--r--core/modules/views/src/Form/ViewsExposedForm.php1
-rw-r--r--core/modules/views/src/Hook/ViewsHooks.php16
-rw-r--r--core/modules/views/src/Hook/ViewsViewsHooks.php26
-rw-r--r--core/modules/views/src/Plugin/views/argument/DayDate.php4
-rw-r--r--core/modules/views/src/Plugin/views/argument/LanguageArgument.php12
-rw-r--r--core/modules/views/src/Plugin/views/argument/MonthDate.php4
-rw-r--r--core/modules/views/src/Plugin/views/argument/YearMonthDate.php4
-rw-r--r--core/modules/views/src/Plugin/views/display/Block.php11
-rw-r--r--core/modules/views/src/Plugin/views/display/DisplayPluginBase.php7
-rw-r--r--core/modules/views/src/Plugin/views/field/Boolean.php5
-rw-r--r--core/modules/views/src/Plugin/views/field/Url.php2
-rw-r--r--core/modules/views/src/Plugin/views/filter/FilterPluginBase.php10
-rw-r--r--core/modules/views/src/Plugin/views/pager/Full.php4
-rw-r--r--core/modules/views/src/Plugin/views/pager/Mini.php3
-rw-r--r--core/modules/views/src/Plugin/views/pager/PagerPluginBase.php8
-rw-r--r--core/modules/views/src/Plugin/views/style/StylePluginBase.php6
-rw-r--r--core/modules/views/src/Plugin/views/style/Table.php2
-rw-r--r--core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php5
-rw-r--r--core/modules/views/src/ViewExecutable.php14
-rw-r--r--core/modules/views/src/ViewsConfigUpdater.php10
22 files changed, 103 insertions, 84 deletions
diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php
index cd1b2a0a42e1..f6bb32cec877 100644
--- a/core/modules/views/src/Entity/View.php
+++ b/core/modules/views/src/Entity/View.php
@@ -481,7 +481,7 @@ class View extends ConfigEntityBase implements ViewEntityInterface {
* {@inheritdoc}
*/
public function onDependencyRemoval(array $dependencies) {
- $changed = FALSE;
+ $changed = parent::onDependencyRemoval($dependencies);
// Don't intervene if the views module is removed.
if (isset($dependencies['module']) && in_array('views', $dependencies['module'])) {
diff --git a/core/modules/views/src/FieldViewsDataProvider.php b/core/modules/views/src/FieldViewsDataProvider.php
index c0b9d50b2d9c..fad34ff460e2 100644
--- a/core/modules/views/src/FieldViewsDataProvider.php
+++ b/core/modules/views/src/FieldViewsDataProvider.php
@@ -139,8 +139,8 @@ class FieldViewsDataProvider {
if (!empty($translatable_configs) && empty($untranslatable_configs)) {
$translation_join_type = 'language';
}
- // If the field is translatable only on certain bundles, there will be a join
- // on langcode OR bundle name.
+ // If the field is translatable only on certain bundles, there will be a
+ // join on langcode OR bundle name.
elseif (!empty($translatable_configs) && !empty($untranslatable_configs)) {
foreach ($untranslatable_configs as $config) {
$untranslatable_config_bundles[] = $config->getTargetBundle();
@@ -268,8 +268,8 @@ class FieldViewsDataProvider {
'help' => $this->t('Appears in: @bundles.', ['@bundles' => implode(', ', $bundles_names)]),
];
- // Go through and create a list of aliases for all possible combinations of
- // entity type + name.
+ // Go through and create a list of aliases for all possible combinations
+ // of entity type + name.
$aliases = [];
$also_known = [];
foreach ($all_labels as $label_name => $true) {
@@ -296,15 +296,15 @@ class FieldViewsDataProvider {
}
if ($aliases) {
$data[$table_alias][$field_alias]['aliases'] = $aliases;
- // The $also_known variable contains markup that is HTML escaped and that
- // loses safeness when imploded. The help text is used in #description
- // and therefore XSS admin filtered by default. Escaped HTML is not
- // altered by XSS filtering, therefore it is safe to just concatenate the
- // strings. Afterwards we mark the entire string as safe, so it won't be
- // escaped, no matter where it is used.
+ // The $also_known variable contains markup that is HTML escaped and
+ // that loses safeness when imploded. The help text is used in
+ // #description and therefore XSS admin filtered by default. Escaped
+ // HTML is not altered by XSS filtering, therefore it is safe to just
+ // concatenate the strings. Afterwards we mark the entire string as
+ // safe, so it won't be escaped, no matter where it is used.
// Considering the dual use of this help data (both as metadata and as
- // help text), other patterns such as use of #markup would not be correct
- // here.
+ // help text), other patterns such as use of #markup would not be
+ // correct here.
$data[$table_alias][$field_alias]['help'] = Markup::create($data[$table_alias][$field_alias]['help'] . ' ' . $this->t('Also known as:') . ' ' . implode(', ', $also_known));
}
@@ -328,7 +328,8 @@ class FieldViewsDataProvider {
foreach ($field_columns as $column => $attributes) {
$allow_sort = TRUE;
- // Identify likely filters and arguments for each column based on field type.
+ // Identify likely filters and arguments for each column based on field
+ // type.
switch ($attributes['type']) {
case 'int':
case 'mediumint':
@@ -387,8 +388,8 @@ class FieldViewsDataProvider {
'help' => $this->t('Appears in: @bundles.', ['@bundles' => implode(', ', $bundles_names)]),
];
- // Go through and create a list of aliases for all possible combinations of
- // entity type + name.
+ // Go through and create a list of aliases for all possible combinations
+ // of entity type + name.
$aliases = [];
$also_known = [];
foreach ($all_labels as $label_name => $true) {
diff --git a/core/modules/views/src/Form/ViewsExposedForm.php b/core/modules/views/src/Form/ViewsExposedForm.php
index d68b1dd5363c..9f90160ff55f 100644
--- a/core/modules/views/src/Form/ViewsExposedForm.php
+++ b/core/modules/views/src/Form/ViewsExposedForm.php
@@ -196,7 +196,6 @@ class ViewsExposedForm extends FormBase implements WorkspaceSafeFormInterface {
$view->exposed_data = $values;
$view->exposed_raw_input = [];
- $exclude = ['submit', 'form_build_id', 'form_id', 'form_token', 'exposed_form_plugin', 'reset'];
/** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase $exposed_form_plugin */
$exposed_form_plugin = $view->display_handler->getPlugin('exposed_form');
$exposed_form_plugin->exposedFormSubmit($form, $form_state, $exclude);
diff --git a/core/modules/views/src/Hook/ViewsHooks.php b/core/modules/views/src/Hook/ViewsHooks.php
index 6facc63de6de..b309887723c3 100644
--- a/core/modules/views/src/Hook/ViewsHooks.php
+++ b/core/modules/views/src/Hook/ViewsHooks.php
@@ -2,6 +2,7 @@
namespace Drupal\views\Hook;
+use Drupal\block\BlockInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\views\ViewsConfigUpdater;
use Drupal\views\ViewEntityInterface;
@@ -378,4 +379,19 @@ class ViewsHooks {
$config_updater->updateAll($view);
}
+ /**
+ * Implements hook_ENTITY_TYPE_presave() for blocks.
+ */
+ #[Hook('block_presave')]
+ public function blockPresave(BlockInterface $block): void {
+ if (str_starts_with($block->getPluginId(), 'views_block:')) {
+ $settings = $block->get('settings');
+ if (isset($settings['items_per_page']) && $settings['items_per_page'] === 'none') {
+ @trigger_error('Saving a views block with "none" items per page is deprecated in drupal:11.2.0 and removed in drupal:12.0.0. To use the items per page defined by the view, use NULL. See https://www.drupal.org/node/3522240', E_USER_DEPRECATED);
+ $settings['items_per_page'] = NULL;
+ $block->set('settings', $settings);
+ }
+ }
+ }
+
}
diff --git a/core/modules/views/src/Hook/ViewsViewsHooks.php b/core/modules/views/src/Hook/ViewsViewsHooks.php
index 531f6c754fa2..4f10f689646c 100644
--- a/core/modules/views/src/Hook/ViewsViewsHooks.php
+++ b/core/modules/views/src/Hook/ViewsViewsHooks.php
@@ -143,8 +143,9 @@ class ViewsViewsHooks {
}
}
// Registers an action bulk form per entity.
+ $all_actions = \Drupal::entityTypeManager()->getStorage('action')->loadMultiple();
foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type => $entity_info) {
- $actions = array_filter(\Drupal::entityTypeManager()->getStorage('action')->loadMultiple(), function (ActionConfigEntityInterface $action) use ($entity_type) {
+ $actions = array_filter($all_actions, function (ActionConfigEntityInterface $action) use ($entity_type) {
return $action->getType() == $entity_type;
});
if (empty($actions)) {
@@ -183,6 +184,7 @@ class ViewsViewsHooks {
if (is_array($result)) {
$data = NestedArray::mergeDeep($result, $data);
}
+ \Drupal::moduleHandler()->invoke($field_storage->getTypeProvider(), 'field_views_data_views_data_alter', [&$data, $field_storage]);
}
}
}
@@ -190,28 +192,6 @@ class ViewsViewsHooks {
}
/**
- * Implements hook_views_data_alter().
- *
- * Field modules can implement hook_field_views_data_views_data_alter() to
- * alter the views data on a per field basis. This is weirdly named so as not
- * to conflict with the \Drupal::moduleHandler()->alter('field_views_data') in
- * views_views_data().
- */
- #[Hook('views_data_alter')]
- public function viewsDataAlter(&$data): void {
- $entity_type_manager = \Drupal::entityTypeManager();
- if (!$entity_type_manager->hasDefinition('field_storage_config')) {
- return;
- }
- /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
- foreach ($entity_type_manager->getStorage('field_storage_config')->loadMultiple() as $field_storage) {
- if (\Drupal::service('views.field_data_provider')->getSqlStorageForField($field_storage)) {
- \Drupal::moduleHandler()->invoke($field_storage->getTypeProvider(), 'field_views_data_views_data_alter', [&$data, $field_storage]);
- }
- }
- }
-
- /**
* Implements hook_field_views_data().
*
* The function implements the hook on behalf of 'core' because it adds a
diff --git a/core/modules/views/src/Plugin/views/argument/DayDate.php b/core/modules/views/src/Plugin/views/argument/DayDate.php
index 884355a72a4b..a4a94da06998 100644
--- a/core/modules/views/src/Plugin/views/argument/DayDate.php
+++ b/core/modules/views/src/Plugin/views/argument/DayDate.php
@@ -29,7 +29,7 @@ class DayDate extends Date {
$day = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT);
// strtotime() respects server timezone, so we need to set the time fixed
// as utc time
- return $this->dateFormatter->format(strtotime("2005" . "05" . $day . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
+ return $this->dateFormatter->format(strtotime("200505" . $day . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
/**
@@ -37,7 +37,7 @@ class DayDate extends Date {
*/
public function title() {
$day = str_pad($this->argument, 2, '0', STR_PAD_LEFT);
- return $this->dateFormatter->format(strtotime("2005" . "05" . $day . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
+ return $this->dateFormatter->format(strtotime("200505" . $day . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
/**
diff --git a/core/modules/views/src/Plugin/views/argument/LanguageArgument.php b/core/modules/views/src/Plugin/views/argument/LanguageArgument.php
index 23980568f764..81a2181dd5a2 100644
--- a/core/modules/views/src/Plugin/views/argument/LanguageArgument.php
+++ b/core/modules/views/src/Plugin/views/argument/LanguageArgument.php
@@ -15,21 +15,19 @@ use Drupal\views\Attribute\ViewsArgument;
class LanguageArgument extends ArgumentPluginBase {
/**
- * Overrides \Drupal\views\Plugin\views\argument\ArgumentPluginBase::summaryName().
- *
- * Gets the user-friendly version of the language name.
+ * {@inheritdoc}
*/
public function summaryName($data) {
+ // Gets the user-friendly version of the language name.
return $this->language($data->{$this->name_alias});
}
/**
- * Overrides \Drupal\views\Plugin\views\argument\ArgumentPluginBase::title().
- *
- * Gets the user friendly version of the language name for display as a
- * title placeholder.
+ * {@inheritdoc}
*/
public function title() {
+ // Gets the user friendly version of the language name for display as a
+ // title placeholder.
return $this->language($this->argument);
}
diff --git a/core/modules/views/src/Plugin/views/argument/MonthDate.php b/core/modules/views/src/Plugin/views/argument/MonthDate.php
index cec2159c9a3d..a24f23f120d9 100644
--- a/core/modules/views/src/Plugin/views/argument/MonthDate.php
+++ b/core/modules/views/src/Plugin/views/argument/MonthDate.php
@@ -28,7 +28,7 @@ class MonthDate extends Date {
public function summaryName($data) {
$month = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT);
try {
- return $this->dateFormatter->format(strtotime("2005" . $month . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
+ return $this->dateFormatter->format(strtotime("2005" . $month . "15 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
catch (\InvalidArgumentException) {
return parent::summaryName($data);
@@ -41,7 +41,7 @@ class MonthDate extends Date {
public function title() {
$month = str_pad($this->argument, 2, '0', STR_PAD_LEFT);
try {
- return $this->dateFormatter->format(strtotime("2005" . $month . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
+ return $this->dateFormatter->format(strtotime("2005" . $month . "15 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
catch (\InvalidArgumentException) {
return parent::title();
diff --git a/core/modules/views/src/Plugin/views/argument/YearMonthDate.php b/core/modules/views/src/Plugin/views/argument/YearMonthDate.php
index 16410ad25564..b82071f6d6ae 100644
--- a/core/modules/views/src/Plugin/views/argument/YearMonthDate.php
+++ b/core/modules/views/src/Plugin/views/argument/YearMonthDate.php
@@ -27,14 +27,14 @@ class YearMonthDate extends Date {
*/
public function summaryName($data) {
$created = $data->{$this->name_alias};
- return $this->dateFormatter->format(strtotime($created . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
+ return $this->dateFormatter->format(strtotime($created . "15 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
/**
* {@inheritdoc}
*/
public function title() {
- return $this->dateFormatter->format(strtotime($this->argument . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
+ return $this->dateFormatter->format(strtotime($this->argument . "15 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
}
diff --git a/core/modules/views/src/Plugin/views/display/Block.php b/core/modules/views/src/Plugin/views/display/Block.php
index 6532990b8d3e..5692ee1df013 100644
--- a/core/modules/views/src/Plugin/views/display/Block.php
+++ b/core/modules/views/src/Plugin/views/display/Block.php
@@ -120,7 +120,7 @@ class Block extends DisplayPluginBase {
* @see \Drupal\views\Plugin\Block\ViewsBlock::defaultConfiguration()
*/
public function blockSettings(array $settings) {
- $settings['items_per_page'] = 'none';
+ $settings['items_per_page'] = NULL;
return $settings;
}
@@ -315,7 +315,7 @@ class Block extends DisplayPluginBase {
40 => 40,
48 => 48,
],
- '#default_value' => $block_configuration['items_per_page'],
+ '#default_value' => $block_configuration['items_per_page'] ?? 'none',
];
break;
}
@@ -353,7 +353,7 @@ class Block extends DisplayPluginBase {
*/
public function blockSubmit(ViewsBlock $block, $form, FormStateInterface $form_state) {
if ($items_per_page = $form_state->getValue(['override', 'items_per_page'])) {
- $block->setConfigurationValue('items_per_page', $items_per_page);
+ $block->setConfigurationValue('items_per_page', $items_per_page === 'none' ? NULL : intval($items_per_page));
}
$form_state->unsetValue(['override', 'items_per_page']);
}
@@ -366,8 +366,9 @@ class Block extends DisplayPluginBase {
*/
public function preBlockBuild(ViewsBlock $block) {
$config = $block->getConfiguration();
- if ($config['items_per_page'] !== 'none') {
- $this->view->setItemsPerPage($config['items_per_page']);
+ if (is_numeric($config['items_per_page']) && $config['items_per_page'] > 0) {
+ // @todo Delete the intval() in https://www.drupal.org/project/drupal/issues/3521221
+ $this->view->setItemsPerPage(intval($config['items_per_page']));
}
}
diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
index fc4a983f9299..d3adc61de5ab 100644
--- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
+++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
@@ -2117,13 +2117,18 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$hasMoreRecords = !empty($this->view->pager) && $this->view->pager->hasMoreRecords();
if ($this->isMoreEnabled() && ($this->useMoreAlways() || $hasMoreRecords)) {
$url = $this->getMoreUrl();
+ $access = $url->access(return_as_object: TRUE);
- return [
+ $more_link = [
'#type' => 'more_link',
'#url' => $url,
'#title' => $this->useMoreText(),
'#view' => $this->view,
+ '#access' => $access->isAllowed(),
];
+ $accessCacheability = CacheableMetadata::createFromObject($access);
+ $accessCacheability->applyTo($more_link);
+ return $more_link;
}
}
diff --git a/core/modules/views/src/Plugin/views/field/Boolean.php b/core/modules/views/src/Plugin/views/field/Boolean.php
index f2eb8f639b87..0c91fdc59509 100644
--- a/core/modules/views/src/Plugin/views/field/Boolean.php
+++ b/core/modules/views/src/Plugin/views/field/Boolean.php
@@ -16,8 +16,9 @@ use Drupal\views\Plugin\views\display\DisplayPluginBase;
* Allows for display of true/false, yes/no, on/off, enabled/disabled.
*
* Definition terms:
- * - output formats: An array where the first entry is displayed on boolean true
- * and the second is displayed on boolean false. An example for sticky is:
+ * - output formats: An array where the first entry is displayed on boolean
+ * true and the second is displayed on boolean false. An example for sticky
+ * is:
* @code
* 'output formats' => [
* 'sticky' => [t('Sticky'), ''],
diff --git a/core/modules/views/src/Plugin/views/field/Url.php b/core/modules/views/src/Plugin/views/field/Url.php
index 18e40a61f0e9..7f5dd0a33653 100644
--- a/core/modules/views/src/Plugin/views/field/Url.php
+++ b/core/modules/views/src/Plugin/views/field/Url.php
@@ -9,7 +9,7 @@ use Drupal\views\Attribute\ViewsField;
use Drupal\views\ResultRow;
/**
- * Field handler to provide simple renderer that turns a URL into a clickable link.
+ * Field handler to provide a renderer that turns a URL into a clickable link.
*
* @ingroup views_field_handlers
*/
diff --git a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php
index e3b5b87ac2ef..0f526735d6e3 100644
--- a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php
+++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php
@@ -889,7 +889,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
* (optional) The form element to set any errors on.
*
* @return string
- * Returns an error message if validation fails, or NULL if validation passes.
+ * The error message if validation fails, or NULL if validation passes.
*/
protected function validateIdentifier($identifier, ?FormStateInterface $form_state = NULL, &$form_group = []) {
$error = '';
@@ -1226,9 +1226,11 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
continue;
}
// Each rows contains three widgets:
- // a) The title, where users define how they identify a pair of operator | value
- // b) The operator
- // c) The value (or values) to use in the filter with the selected operator
+ // - The title, where users define how they identify a pair of
+ // operator | value.
+ // - The operator.
+ // - The value (or values) to use in the filter with the selected
+ // operator.
// In each row, we have to display the operator form and the value from
// $row acts as a fake form to render each widget in a row.
diff --git a/core/modules/views/src/Plugin/views/pager/Full.php b/core/modules/views/src/Plugin/views/pager/Full.php
index 0176fc6e7f90..ed8f7d7566a2 100644
--- a/core/modules/views/src/Plugin/views/pager/Full.php
+++ b/core/modules/views/src/Plugin/views/pager/Full.php
@@ -79,8 +79,8 @@ class Full extends SqlBase {
* {@inheritdoc}
*/
public function render($input) {
- // The 0, 1, 3, 4 indexes are correct. See the template_preprocess_pager()
- // documentation.
+ // The 0, 1, 3, 4 indexes are correct. See the
+ // \Drupal\Core\Pager\PagerPreprocess::preprocessPager() documentation.
$tags = [
0 => $this->options['tags']['first'],
1 => $this->options['tags']['previous'],
diff --git a/core/modules/views/src/Plugin/views/pager/Mini.php b/core/modules/views/src/Plugin/views/pager/Mini.php
index 0f95f7a0d2f6..e17aa7fabdd7 100644
--- a/core/modules/views/src/Plugin/views/pager/Mini.php
+++ b/core/modules/views/src/Plugin/views/pager/Mini.php
@@ -90,7 +90,8 @@ class Mini extends SqlBase {
* {@inheritdoc}
*/
public function render($input) {
- // The 1, 3 indexes are correct, see template_preprocess_pager().
+ // The 1, 3 indexes are correct, see
+ // \Drupal\Core\Pager\PagerPreprocess::preprocessPager().
$tags = [
1 => $this->options['tags']['previous'],
3 => $this->options['tags']['next'],
diff --git a/core/modules/views/src/Plugin/views/pager/PagerPluginBase.php b/core/modules/views/src/Plugin/views/pager/PagerPluginBase.php
index 3356d703c93d..5796488746cc 100644
--- a/core/modules/views/src/Plugin/views/pager/PagerPluginBase.php
+++ b/core/modules/views/src/Plugin/views/pager/PagerPluginBase.php
@@ -29,14 +29,18 @@ abstract class PagerPluginBase extends PluginBase {
/**
* The current page.
+ *
+ * @phpcs:ignore Drupal.Commenting.VariableComment.MissingVar
*/
- // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName, Drupal.Commenting.VariableComment.Missing
+ // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName
public $current_page = NULL;
/**
* The total number of lines.
+ *
+ * @phpcs:ignore Drupal.Commenting.VariableComment.MissingVar
*/
- // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName, Drupal.Commenting.VariableComment.Missing
+ // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName
public $total_items = 0;
/**
diff --git a/core/modules/views/src/Plugin/views/style/StylePluginBase.php b/core/modules/views/src/Plugin/views/style/StylePluginBase.php
index 3f555cfec9fd..ca8df3ba8fef 100644
--- a/core/modules/views/src/Plugin/views/style/StylePluginBase.php
+++ b/core/modules/views/src/Plugin/views/style/StylePluginBase.php
@@ -85,12 +85,12 @@ abstract class StylePluginBase extends PluginBase {
/**
* Stores the rendered field values, keyed by the row index and field name.
*
+ * @var array|null
+ *
* @see \Drupal\views\Plugin\views\style\StylePluginBase::renderFields()
* @see \Drupal\views\Plugin\views\style\StylePluginBase::getField()
- *
- * @var array|null
*/
- // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName, Drupal.Commenting.VariableComment.Missing
+ // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName
protected $rendered_fields;
/**
diff --git a/core/modules/views/src/Plugin/views/style/Table.php b/core/modules/views/src/Plugin/views/style/Table.php
index 48adbf427ede..561628ac6820 100644
--- a/core/modules/views/src/Plugin/views/style/Table.php
+++ b/core/modules/views/src/Plugin/views/style/Table.php
@@ -71,7 +71,7 @@ class Table extends StylePluginBase implements CacheableDependencyInterface {
$options = parent::defineOptions();
$options['columns'] = ['default' => []];
- $options['class'] = ['default' => []];
+ $options['class'] = ['default' => ''];
$options['default'] = ['default' => ''];
$options['info'] = ['default' => []];
$options['override'] = ['default' => TRUE];
diff --git a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php
index ef8568203cd4..d53e93cecec1 100644
--- a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php
+++ b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php
@@ -208,7 +208,8 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
* Gets the availableSorts property.
*
* @return array
- * An array of available sorts, keyed by sort ID, containing sort information.
+ * An array whose keys are the available sort options and whose
+ * corresponding values are human readable labels.
*/
public function getAvailableSorts() {
return $this->availableSorts;
@@ -483,7 +484,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
}
/**
- * Gets the current value of a #select element, from within a form constructor function.
+ * Gets the current value of a #select element.
*
* This function is intended for use in highly dynamic forms (in particular
* the add view wizard) which are rebuilt in different ways depending on which
diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php
index 55e3a8d91453..407260ed285d 100644
--- a/core/modules/views/src/ViewExecutable.php
+++ b/core/modules/views/src/ViewExecutable.php
@@ -348,7 +348,7 @@ class ViewExecutable {
public $footer;
/**
- * Stores the area handlers for the empty text which are initialized on this view.
+ * The area handlers for the empty text which are initialized on this view.
*
* An array containing Drupal\views\Plugin\views\area\AreaPluginBase objects.
*
@@ -400,21 +400,21 @@ class ViewExecutable {
/**
* Force the query to calculate the total number of results.
*
- * @todo Move to the query.
- *
* @var bool
+ *
+ * @todo Move to the query.
*/
- // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName, Drupal.Commenting.VariableComment.Missing
+ // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName
public $get_total_rows;
/**
* Indicates if the sorts have been built.
*
- * @todo Group with other static properties.
- *
* @var bool
+ *
+ * @todo Group with other static properties.
*/
- // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName, Drupal.Commenting.VariableComment.Missing
+ // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName
public $build_sort;
/**
diff --git a/core/modules/views/src/ViewsConfigUpdater.php b/core/modules/views/src/ViewsConfigUpdater.php
index 3b2709cc60c2..9c5d38e10ac5 100644
--- a/core/modules/views/src/ViewsConfigUpdater.php
+++ b/core/modules/views/src/ViewsConfigUpdater.php
@@ -134,6 +134,9 @@ class ViewsConfigUpdater implements ContainerInjectionInterface {
if ($this->processRememberRolesUpdate($handler, $handler_type)) {
$changed = TRUE;
}
+ if ($this->processTableCssClassUpdate($view)) {
+ $changed = TRUE;
+ }
return $changed;
});
}
@@ -335,6 +338,7 @@ class ViewsConfigUpdater implements ContainerInjectionInterface {
if (
isset($display['display_options']['style']) &&
$display['display_options']['style']['type'] === 'table' &&
+ isset($display['display_options']['style']['options']) &&
!isset($display['display_options']['style']['options']['class'])
) {
$display['display_options']['style']['options']['class'] = '';
@@ -346,6 +350,12 @@ class ViewsConfigUpdater implements ContainerInjectionInterface {
$view->set('display', $displays);
}
+ $deprecations_triggered = &$this->triggeredDeprecations['table_css_class'][$view->id()];
+ if ($this->deprecationsEnabled && $changed && !$deprecations_triggered) {
+ $deprecations_triggered = TRUE;
+ @trigger_error(sprintf('The update to add a default table CSS class for view "%s" is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Profile, module and theme provided configuration should be updated. See https://www.drupal.org/node/3499943', $view->id()), E_USER_DEPRECATED);
+ }
+
return $changed;
}