Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / views / src / Plugin / views / display / DisplayPluginBase.php
index e31b5a295f477907b6bcebed5c6a34b57d5ed0d2..4f1cb2ecd55f9eb956275fe8dfcaebb60f19c96d 100644 (file)
@@ -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('<span>@text</span>', ['@text' => $text]);
+      $text = new FormattableMarkup('<span>@text</span>', ['@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.'),
     ];
   }