X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fviews%2Fsrc%2FPlugin%2Fviews%2Fdisplay%2FDisplayPluginBase.php;h=4f1cb2ecd55f9eb956275fe8dfcaebb60f19c96d;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=e31b5a295f477907b6bcebed5c6a34b57d5ed0d2;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index e31b5a295..4f1cb2ecd 100644 --- a/web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -4,7 +4,7 @@ namespace Drupal\views\Plugin\views\display; use Drupal\Component\Plugin\DependentPluginInterface; use Drupal\Component\Utility\Html; -use Drupal\Component\Utility\SafeMarkup; +use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\CacheableDependencyInterface; @@ -164,7 +164,6 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte } } - $this->setOptionDefaults($this->options, $this->defineOptions()); $this->display = &$display; @@ -234,7 +233,9 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte /** * {@inheritdoc} */ - public function isDefaultDisplay() { return FALSE; } + public function isDefaultDisplay() { + return FALSE; + } /** * {@inheritdoc} @@ -394,7 +395,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte /** * {@inheritdoc} */ - public function attachTo(ViewExecutable $view, $display_id, array &$build) { } + public function attachTo(ViewExecutable $view, $display_id, array &$build) {} /** * {@inheritdoc} @@ -665,17 +666,23 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte /** * {@inheritdoc} */ - public function hasPath() { return FALSE; } + public function hasPath() { + return FALSE; + } /** * {@inheritdoc} */ - public function usesLinkDisplay() { return !$this->hasPath(); } + public function usesLinkDisplay() { + return !$this->hasPath(); + } /** * {@inheritdoc} */ - public function usesExposedFormInBlock() { return $this->hasPath(); } + public function usesExposedFormInBlock() { + return $this->hasPath(); + } /** * {@inheritdoc} @@ -772,7 +779,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte return $this->default_display->getOption($option); } - if (array_key_exists($option, $this->options)) { + if (isset($this->options[$option]) || array_key_exists($option, $this->options)) { return $this->options[$option]; } } @@ -955,7 +962,6 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte return $this->dependencies; } - /** * {@inheritdoc} */ @@ -1015,7 +1021,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte } if (!empty($class)) { - $text = SafeMarkup::format('@text', ['@text' => $text]); + $text = new FormattableMarkup('@text', ['@text' => $text]); } if (empty($title)) { @@ -1026,13 +1032,13 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte 'js' => 'nojs', 'view' => $this->view->storage->id(), 'display_id' => $this->display['id'], - 'type' => $section + 'type' => $section, ], [ 'attributes' => [ 'class' => ['views-ajax-link', $class], 'title' => $title, - 'id' => Html::getUniqueId('views-' . $this->display['id'] . '-' . $section) - ] + 'id' => Html::getUniqueId('views-' . $this->display['id'] . '-' . $section), + ], ])); } @@ -1463,7 +1469,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte '#title' => $this->t('Show contextual links'), '#default_value' => $this->getOption('show_admin_links'), ]; - break; + break; case 'use_more': $form['#title'] .= $this->t('Add a more link to the bottom of the display.'); $form['use_more'] = [ @@ -1858,7 +1864,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte if (preg_match('/[^a-zA-Z0-9-_ ]/', $css_class)) { $form_state->setError($form['css_class'], $this->t('CSS classes must be alphanumeric or dashes only.')); } - break; + break; case 'display_id': if ($form_state->getValue('display_id')) { if (preg_match('/[^a-z0-9_]/', $form_state->getValue('display_id'))) { @@ -2051,7 +2057,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte /** * {@inheritdoc} */ - public function renderFilters() { } + public function renderFilters() {} /** * {@inheritdoc} @@ -2115,7 +2121,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte '#cache' => &$this->view->element['#cache'], ]; - $this->applyDisplayCachablityMetadata($this->view->element); + $this->applyDisplayCacheabilityMetadata($this->view->element); return $element; } @@ -2126,7 +2132,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte * @param array $element * The render array with updated cacheability metadata. */ - protected function applyDisplayCachablityMetadata(array &$element) { + protected function applyDisplayCacheabilityMetadata(array &$element) { /** @var \Drupal\views\Plugin\views\cache\CachePluginBase $cache */ $cache = $this->getPlugin('cache'); @@ -2138,6 +2144,22 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte ->applyTo($element); } + /** + * Applies the cacheability of the current display to the given render array. + * + * @param array $element + * The render array with updated cacheability metadata. + * + * @deprecated in Drupal 8.4.0, will be removed before Drupal 9.0. Use + * DisplayPluginBase::applyDisplayCacheabilityMetadata instead. + * + * @see \Drupal\views\Plugin\views\display\DisplayPluginBase::applyDisplayCacheabilityMetadata() + */ + protected function applyDisplayCachablityMetadata(array &$element) { + @trigger_error('The DisplayPluginBase::applyDisplayCachablityMetadata method is deprecated since version 8.4 and will be removed in 9.0. Use DisplayPluginBase::applyDisplayCacheabilityMetadata instead.', E_USER_DEPRECATED); + $this->applyDisplayCacheabilityMetadata($element); + } + /** * {@inheritdoc} */ @@ -2309,7 +2331,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte /** * {@inheritdoc} */ - public function execute() { } + public function execute() {} /** * {@inheritdoc} @@ -2330,7 +2352,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte // of cacheability metadata (e.g.: cache contexts), so they can bubble up. // Thus, we add the cacheability metadata first, then modify / remove the // cache keys depending on the $cache argument. - $this->applyDisplayCachablityMetadata($this->view->element); + $this->applyDisplayCacheabilityMetadata($this->view->element); if ($cache) { $this->view->element['#cache'] += ['keys' => []]; // Places like \Drupal\views\ViewExecutable::setCurrentPage() set up an @@ -2564,7 +2586,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte public function getPagerText() { return [ 'items per page title' => $this->t('Items to display'), - 'items per page description' => $this->t('Enter 0 for no limit.') + 'items per page description' => $this->t('Enter 0 for no limit.'), ]; }