From 21a78c53f586b0eee463468e0d30025a4a84c03e Mon Sep 17 00:00:00 2001
From: bellesmanieres <bellesmanieres@320744.no-reply.drupal.org>
Date: Sun, 26 Aug 2012 20:36:38 +0200
Subject: [PATCH] Issue #1756656 by bellesmanieres | tim.plunkett: Move
 uses_grouping() from plugin annotation to a class property.

---
 .../views/Plugin/views/style/DefaultStyle.php |  1 -
 .../Plugin/views/style/StylePluginBase.php    | 27 ++++++++++++++-----
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/lib/Drupal/views/Plugin/views/style/DefaultStyle.php b/lib/Drupal/views/Plugin/views/style/DefaultStyle.php
index 05e2cb32e639..a98c3faa1860 100644
--- a/lib/Drupal/views/Plugin/views/style/DefaultStyle.php
+++ b/lib/Drupal/views/Plugin/views/style/DefaultStyle.php
@@ -21,7 +21,6 @@
  *   title = @Translation("Unformatted list"),
  *   help = @Translation("Displays rows one after another."),
  *   theme = "views_view_unformatted",
- *   uses_grouping = TRUE,
  *   type = "normal",
  *   help_topic = "style-unformatted"
  * )
diff --git a/lib/Drupal/views/Plugin/views/style/StylePluginBase.php b/lib/Drupal/views/Plugin/views/style/StylePluginBase.php
index a8d2f45300fe..74d30f332e5c 100644
--- a/lib/Drupal/views/Plugin/views/style/StylePluginBase.php
+++ b/lib/Drupal/views/Plugin/views/style/StylePluginBase.php
@@ -63,6 +63,13 @@ abstract class StylePluginBase extends PluginBase {
    */
   protected $usesRowClass = FALSE;
 
+  /**
+   * Does the style plugin support grouping of rows.
+   *
+   * @var bool
+   */
+  protected $usesGrouping = TRUE;
+
   /**
    * Does the style plugin for itself support to add fields to it's output.
    *
@@ -97,9 +104,6 @@ function init(&$view, &$display, $options = NULL) {
       'grouping' => array(),
     );
 
-    $this->definition += array(
-      'uses_grouping' => TRUE,
-    );
   }
 
   function destroy() {
@@ -129,6 +133,15 @@ function usesRowClass() {
     return $this->usesRowClass;
   }
 
+  /**
+   * Returns the usesGrouping property.
+   *
+   * @return bool
+   */
+  function usesGrouping() {
+    return $this->usesGrouping;
+  }
+
   /**
    * Return TRUE if this style also uses fields.
    *
@@ -224,10 +237,10 @@ function option_definition() {
   function options_form(&$form, &$form_state) {
     parent::options_form($form, $form_state);
     // Only fields-based views can handle grouping.  Style plugins can also exclude
-    // themselves from being groupable by setting their "use grouping" definiton
-    // key to FALSE.
-    // @TODO: Document "uses grouping" in docs.php when docs.php is written.
-    if ($this->usesFields() && $this->definition['uses_grouping']) {
+    // themselves from being groupable by setting their "usesGrouping" property
+    // to FALSE.
+    // @TODO: Document "usesGrouping" in docs.php when docs.php is written.
+    if ($this->usesFields() && $this->usesGrouping()) {
       $options = array('' => t('- None -'));
       $field_labels = $this->display->handler->get_field_labels(TRUE);
       $options += $field_labels;
-- 
GitLab