Commit b69517a8 authored by alexpott's avatar alexpott

Revert "Issue #2662548 by robertwb: Support Plugins for Views Aggregate"

This reverts commit 72b17f95.
parent 68a1fbc7
<?php
/**
* @file
* Contains \Drupal\views\Annotation\ViewsAggregate.
*/
namespace Drupal\views\Annotation;
/**
* Defines a Plugin annotation object for views aggregate plugins.
*
* @see \Drupal\views\Plugin\views\aggregate\AggregatePluginBase
*
* @ingroup views_aggregate_plugins
*
* @Annotation
*/
class ViewsAggregate extends ViewsPluginAnnotationBase {
/**
* The plugin ID.
*
* @var string
*/
public $id;
/**
* The plugin title used in the views UI.
*
* @var \Drupal\Core\Annotation\Translation
*
* @ingroup plugin_translatable
*/
public $title = '';
/**
* (optional) The short title used in the views UI.
*
* @var \Drupal\Core\Annotation\Translation
*
* @ingroup plugin_translatable
*/
public $short_title = '';
/**
* A short help string; this is displayed in the views UI.
*
* @var \Drupal\Core\Annotation\Translation
*
* @ingroup plugin_translatable
*/
public $help = '';
/**
* An external function to use for this plugin instead of the plugin name.
*
* @var string
*/
public $function = '';
/**
* An function external to the class to use for this plugin. This is the default in D7.
*
* @var string
*/
public $method = '';
/**
* The Views handler use for this plugin.
*
* @var list
*/
public $handler = array();
/**
* Whether the plugin should be not selectable in the UI.
*
* If it's set to TRUE, you can still use it via the API in config files.
*
* @var bool
*/
public $no_ui;
}
<?php
/**
* @file
* Contains \Drupal\views\Plugin\views\aggregate\AggregatePluginBase.
*/
namespace Drupal\views\Plugin\views\aggregate;
use Drupal\views\Plugin\views\PluginBase;
/**
* @defgroup views_aggregate_plugins Views query aggregate plugins
* @{
* Plugins to handle query aggregates in views.
*
* Aggregates allow access to aggregate function provided by SQL and database extensions.
*
* Aggregate plugins extend \Drupal\views\Plugin\views\aggregate\AggregatePluginBase. They
* must be annotated with \Drupal\views\Annotation\ViewsAggregate annotation,
* and they must be in namespace directory Plugin\views\aggregate.
*
* @ingroup views_aggregate_plugins
* @see plugin_api
*/
/**
* Base class for views aggregate plugins.
*/
abstract class AggregatePluginBase extends PluginBase {
}
/**
* @}
*/
<?php
namespace Drupal\views\Plugin\views\aggregate;
use Drupal\views\Plugin\views\PluginBase;
/**
* Aggregate plugin for SQL AVG function.
*
* @ViewsAggregate(
* id = "avg",
* function = "avg",
* title = @Translation("Average"),
* method = "aggregationMethodSimple",
* handler = {
* "argument" = "groupby_numeric",
* "field" = "numeric",
* "filter" = "groupby_numeric",
* "sort" = "groupby_numeric"
* },
* help = @Translation("Average."),
* )
*/
class Avg extends AggregatePluginBase {
// Class methods…
}
\ No newline at end of file
<?php
namespace Drupal\views\Plugin\views\aggregate;
use Drupal\views\Plugin\views\PluginBase;
/**
* Aggregate plugin for SQL COUNT function.
*
* @ViewsAggregate(
* id = "count",
* function = "count",
* title = @Translation("Count"),
* method = "aggregationMethodSimple",
* handler = {
* "argument" = "groupby_numeric",
* "field" = "numeric",
* "filter" = "groupby_numeric",
* "sort" = "groupby_numeric"
* },
* help = @Translation("Count."),
* )
*/
class Count extends AggregatePluginBase {
// Class methods…
}
\ No newline at end of file
<?php
namespace Drupal\views\Plugin\views\aggregate;
use Drupal\views\Plugin\views\PluginBase;
/**
* Aggregate plugin for SQL COUNT DISTINCT function.
*
* @ViewsAggregate(
* id = "count_distinct",
* function = "count distinct",
* title = @Translation("Count DISTINCT"),
* method = "aggregationMethodDistinct",
* handler = {
* "argument" = "groupby_numeric",
* "field" = "numeric",
* "filter" = "groupby_numeric",
* "sort" = "groupby_numeric"
* },
* help = @Translation("Count DISTINCT."),
* )
*/
class Count_Distinct extends AggregatePluginBase {
// Class methods…
}
\ No newline at end of file
<?php
namespace Drupal\views\Plugin\views\aggregate;
use Drupal\views\Plugin\views\PluginBase;
/**
* Aggregate plugin for SQL MAX function.
*
* @ViewsAggregate(
* id = "max",
* function = "max",
* title = @Translation("Maximum"),
* method = "aggregationMethodSimple",
* handler = {
* "argument" = "groupby_numeric",
* "field" = "numeric",
* "filter" = "groupby_numeric",
* "sort" = "groupby_numeric"
* },
* help = @Translation("Maximum."),
* )
*/
class Max extends AggregatePluginBase {
// Class methods…
}
\ No newline at end of file
<?php
namespace Drupal\views\Plugin\views\aggregate;
use Drupal\views\Plugin\views\PluginBase;
/**
* Aggregate plugin for SQL Median function.
*
* @ViewsAggregate(
* id = "median",
* function = "median",
* title = @Translation("Median"),
* method = "aggregationMethodSimple",
* handler = {
* "argument" = "views_handler_argument_group_by_numeric",
* "filter" = "views_handler_filter_group_by_numeric",
* "sort" = "views_handler_sort_group_by_numeric"
* },
* help = @Translation("Median."),
* )
*/
class Median extends AggregatePluginBase {
// Class methods…
}
\ No newline at end of file
<?php
namespace Drupal\views\Plugin\views\aggregate;
use Drupal\views\Plugin\views\PluginBase;
/**
* Aggregate plugin for SQL MIN function.
*
* @ViewsAggregate(
* id = "min",
* function = "min",
* title = @Translation("Minimum"),
* method = "aggregationMethodSimple",
* handler = {
* "argument" = "groupby_numeric",
* "field" = "numeric",
* "filter" = "groupby_numeric",
* "sort" = "groupby_numeric"
* },
* help = @Translation("Minimum."),
* )
*/
class Min extends AggregatePluginBase {
// Class methods…
}
\ No newline at end of file
<?php
namespace Drupal\views\Plugin\views\aggregate;
use Drupal\views\Plugin\views\PluginBase;
/**
* Aggregate plugin for SQL STDDEV_POPfunction.
*
* @ViewsAggregate(
* id = "stddev_pop",
* function = "stddev_pop",
* title = @Translation("Standard deviation (pop)"),
* method = "aggregationMethodSimple",
* handler = {
* "argument" = "groupby_numeric",
* "field" = "numeric",
* "filter" = "groupby_numeric",
* "sort" = "groupby_numeric"
* },
* help = @Translation("Population Standard Deviation."),
* )
*/
class Stddev_Pop extends AggregatePluginBase {
// Class methods…
}
\ No newline at end of file
<?php
namespace Drupal\views\Plugin\views\aggregate;
use Drupal\views\Plugin\views\PluginBase;
/**
* Aggregate plugin for SQL stddev_samp function.
*
* @ViewsAggregate(
* id = "stddev_samp",
* function = "stddev_samp",
* title = @Translation("Standard deviation (sample)"),
* method = "aggregationMethodSimple",
* handler = {
* "argument" = "groupby_numeric",
* "field" = "numeric",
* "filter" = "groupby_numeric",
* "sort" = "groupby_numeric"
* },
* help = @Translation("Population Standard Deviation."),
* )
*/
class Stddev_Samp extends AggregatePluginBase {
// Class methods…
}
\ No newline at end of file
<?php
namespace Drupal\views\Plugin\views\aggregate;
use Drupal\views\Plugin\views\PluginBase;
/**
* Aggregate plugin for SQL SUM function.
*
* @ViewsAggregate(
* id = "sum",
* function = "sum",
* title = @Translation("Sum"),
* method = "aggregationMethodSimple",
* handler = {
* "argument" = "groupby_numeric",
* "field" = "numeric",
* "filter" = "groupby_numeric",
* "sort" = "groupby_numeric"
* },
* help = @Translation("Sum."),
* )
*/
class Sum extends AggregatePluginBase {
// Class methods…
}
\ No newline at end of file
......@@ -1597,16 +1597,84 @@ public function addSignature(ViewExecutable $view) {
}
public function getAggregationInfo() {
// Find plugins for database specific and customized aggregation.
$type = \Drupal::service('plugin.manager.views.aggregate');
$plugin_definitions = $type->getDefinitions();
asort($plugin_definitions);
// @todo -- need a way to get database specific and customized aggregation
// functions into here.
return array(
'group' => array(
'title' => $this->t('Group results together'),
'is aggregate' => FALSE,
),
) + $plugin_definitions;
'count' => array(
'title' => $this->t('Count'),
'method' => 'aggregationMethodSimple',
'handler' => array(
'argument' => 'groupby_numeric',
'field' => 'numeric',
'filter' => 'groupby_numeric',
'sort' => 'groupby_numeric',
),
),
'count_distinct' => array(
'title' => $this->t('Count DISTINCT'),
'method' => 'aggregationMethodDistinct',
'handler' => array(
'argument' => 'groupby_numeric',
'field' => 'numeric',
'filter' => 'groupby_numeric',
'sort' => 'groupby_numeric',
),
),
'sum' => array(
'title' => $this->t('Sum'),
'method' => 'aggregationMethodSimple',
'handler' => array(
'argument' => 'groupby_numeric',
'field' => 'numeric',
'filter' => 'groupby_numeric',
'sort' => 'groupby_numeric',
),
),
'avg' => array(
'title' => $this->t('Average'),
'method' => 'aggregationMethodSimple',
'handler' => array(
'argument' => 'groupby_numeric',
'field' => 'numeric',
'filter' => 'groupby_numeric',
'sort' => 'groupby_numeric',
),
),
'min' => array(
'title' => $this->t('Minimum'),
'method' => 'aggregationMethodSimple',
'handler' => array(
'argument' => 'groupby_numeric',
'field' => 'numeric',
'filter' => 'groupby_numeric',
'sort' => 'groupby_numeric',
),
),
'max' => array(
'title' => $this->t('Maximum'),
'method' => 'aggregationMethodSimple',
'handler' => array(
'argument' => 'groupby_numeric',
'field' => 'numeric',
'filter' => 'groupby_numeric',
'sort' => 'groupby_numeric',
),
),
'stddev_pop' => array(
'title' => $this->t('Standard deviation'),
'method' => 'aggregationMethodSimple',
'handler' => array(
'argument' => 'groupby_numeric',
'field' => 'numeric',
'filter' => 'groupby_numeric',
'sort' => 'groupby_numeric',
),
)
);
}
public function aggregationMethodSimple($group_type, $field) {
......
......@@ -56,9 +56,6 @@ services:
plugin.manager.views.wizard:
class: Drupal\views\Plugin\ViewsPluginManager
arguments: [wizard, '@container.namespaces', '@cache.discovery', '@module_handler']
plugin.manager.views.aggregate:
class: Drupal\views\Plugin\ViewsPluginManager
arguments: [aggregate, '@container.namespaces', '@cache.discovery', '@module_handler']
views.views_data:
class: Drupal\views\ViewsData
arguments: ['@cache.discovery', '@config.factory', '@module_handler', '@language_manager']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment