summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbellesmanieres2012-08-26 18:36:38 (GMT)
committerTim Plunkett2012-10-22 02:48:38 (GMT)
commit21a78c53f586b0eee463468e0d30025a4a84c03e (patch)
treea91620b916e0be993f6c27501a1269cca9ff4f41
parent7d3972ecdf5f45434ca5c17ab8321ea73871631a (diff)
Issue #1756656 by bellesmanieres | tim.plunkett: Move uses_grouping() from plugin annotation to a class property.
-rw-r--r--lib/Drupal/views/Plugin/views/style/DefaultStyle.php1
-rw-r--r--lib/Drupal/views/Plugin/views/style/StylePluginBase.php27
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 05e2cb3..a98c3fa 100644
--- a/lib/Drupal/views/Plugin/views/style/DefaultStyle.php
+++ b/lib/Drupal/views/Plugin/views/style/DefaultStyle.php
@@ -21,7 +21,6 @@ use Drupal\Core\Annotation\Translation;
* 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 a8d2f45..74d30f3 100644
--- a/lib/Drupal/views/Plugin/views/style/StylePluginBase.php
+++ b/lib/Drupal/views/Plugin/views/style/StylePluginBase.php
@@ -64,6 +64,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.
*
* This option only makes sense on style plugins without row plugins, like
@@ -97,9 +104,6 @@ abstract class StylePluginBase extends PluginBase {
'grouping' => array(),
);
- $this->definition += array(
- 'uses_grouping' => TRUE,
- );
}
function destroy() {
@@ -130,6 +134,15 @@ abstract class StylePluginBase extends PluginBase {
}
/**
+ * Returns the usesGrouping property.
+ *
+ * @return bool
+ */
+ function usesGrouping() {
+ return $this->usesGrouping;
+ }
+
+ /**
* Return TRUE if this style also uses fields.
*
* @return bool
@@ -224,10 +237,10 @@ abstract class StylePluginBase extends PluginBase {
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;