From d21b68845183997d53744c68488c4a88e878beea Mon Sep 17 00:00:00 2001 From: Daniel Wehner <daniel.wehner@erdfisch.de> Date: Sat, 28 Jul 2012 10:36:16 -0500 Subject: [PATCH] convert more filters to annotations --- .../views/Plugins/views/filter/BooleanOperator.php | 8 ++++++++ .../Plugins/views/filter/BooleanOperatorString.php | 8 ++++++++ lib/Drupal/views/Plugins/views/filter/Combine.php | 8 ++++++++ lib/Drupal/views/Plugins/views/filter/Equality.php | 8 ++++++++ .../views/Plugins/views/filter/GroupByNumeric.php | 8 ++++++++ .../views/Plugins/views/filter/InOperator.php | 8 ++++++++ .../views/Plugins/views/filter/ManyToOne.php | 8 ++++++++ lib/Drupal/views/Plugins/views/query/Sql.php | 14 +++++++------- modules/comment.views.inc | 2 +- modules/locale.views.inc | 2 +- modules/node.views.inc | 12 ++++++------ modules/poll.views.inc | 2 +- modules/search.views.inc | 4 ++-- modules/statistics.views.inc | 4 ++-- modules/system.views.inc | 4 ++-- modules/translation.views.inc | 2 +- modules/user.views.inc | 10 +++++----- modules/views.views.inc | 2 +- views.api.php | 2 +- 19 files changed, 86 insertions(+), 30 deletions(-) diff --git a/lib/Drupal/views/Plugins/views/filter/BooleanOperator.php b/lib/Drupal/views/Plugins/views/filter/BooleanOperator.php index c495b1747e5e..8aa665bee509 100644 --- a/lib/Drupal/views/Plugins/views/filter/BooleanOperator.php +++ b/lib/Drupal/views/Plugins/views/filter/BooleanOperator.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugins\views\filter; +use Drupal\Core\Annotation\Plugin; + /** * Simple filter to handle matching of boolean values * @@ -23,6 +25,12 @@ * * @ingroup views_filter_handlers */ + +/** + * @plugin( + * plugin_id = "boolean" + * ) + */ class BooleanOperator extends FilterPluginBase { // exposed filter options diff --git a/lib/Drupal/views/Plugins/views/filter/BooleanOperatorString.php b/lib/Drupal/views/Plugins/views/filter/BooleanOperatorString.php index 910dbfca47f1..1d6a7ed9eba5 100644 --- a/lib/Drupal/views/Plugins/views/filter/BooleanOperatorString.php +++ b/lib/Drupal/views/Plugins/views/filter/BooleanOperatorString.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugins\views\filter; +use Drupal\Core\Annotation\Plugin; + /** * Simple filter to handle matching of boolean values. * @@ -18,6 +20,12 @@ * * @ingroup views_filter_handlers */ + +/** + * @plugin( + * plugid_id = "boolean_string" + * ) + */ class BooleanOperatorString extends BooleanOperator { function query() { $this->ensure_my_table(); diff --git a/lib/Drupal/views/Plugins/views/filter/Combine.php b/lib/Drupal/views/Plugins/views/filter/Combine.php index 149512764d61..48218e60d017 100644 --- a/lib/Drupal/views/Plugins/views/filter/Combine.php +++ b/lib/Drupal/views/Plugins/views/filter/Combine.php @@ -7,11 +7,19 @@ namespace Drupal\views\Plugins\views\filter; +use Drupal\Core\Annotation\Plugin; + /** * Filter handler which allows to search on multiple fields. * * @ingroup views_field_handlers */ + +/** + * @plugin( + * plugin_id = "combine" + * ) + */ class Combine extends String { /** * @var views_plugin_query_default diff --git a/lib/Drupal/views/Plugins/views/filter/Equality.php b/lib/Drupal/views/Plugins/views/filter/Equality.php index 7e46c096851c..2602ad18ca6a 100644 --- a/lib/Drupal/views/Plugins/views/filter/Equality.php +++ b/lib/Drupal/views/Plugins/views/filter/Equality.php @@ -7,11 +7,19 @@ namespace Drupal\views\Plugins\views\filter; +use Drupal\Core\Annotation\Plugin; + /** * Simple filter to handle equal to / not equal to filters * * @ingroup views_filter_handlers */ + +/** + * @plugin( + * plugin_id = "equality" + * ) + */ class Equality extends FilterPluginBase { // exposed filter options var $always_multiple = TRUE; diff --git a/lib/Drupal/views/Plugins/views/filter/GroupByNumeric.php b/lib/Drupal/views/Plugins/views/filter/GroupByNumeric.php index c9a75211679b..a47b83f33d57 100644 --- a/lib/Drupal/views/Plugins/views/filter/GroupByNumeric.php +++ b/lib/Drupal/views/Plugins/views/filter/GroupByNumeric.php @@ -7,11 +7,19 @@ namespace Drupal\views\Plugins\views\filter; +use Drupal\Core\Annotation\Plugin; + /** * Simple filter to handle greater than/less than filters * * @ingroup views_filter_handlers */ + +/** + * @plugin( + * plugin_id = "groupby_numeric" + * ) + */ class GroupByNumeric extends Numeric { function query() { $this->ensure_my_table(); diff --git a/lib/Drupal/views/Plugins/views/filter/InOperator.php b/lib/Drupal/views/Plugins/views/filter/InOperator.php index d060d9f35b7b..fa1510516413 100644 --- a/lib/Drupal/views/Plugins/views/filter/InOperator.php +++ b/lib/Drupal/views/Plugins/views/filter/InOperator.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugins\views\filter; +use Drupal\Core\Annotation\Plugin; + /** * Simple filter to handle matching of multiple options selectable via checkboxes * @@ -16,6 +18,12 @@ * * @ingroup views_filter_handlers */ + +/** + * @plugin( + * plugin_id = "in_operator" + * ) + */ class InOperator extends FilterPluginBase { var $value_form_type = 'checkboxes'; diff --git a/lib/Drupal/views/Plugins/views/filter/ManyToOne.php b/lib/Drupal/views/Plugins/views/filter/ManyToOne.php index 095c2adcb2d5..793c3839edb5 100644 --- a/lib/Drupal/views/Plugins/views/filter/ManyToOne.php +++ b/lib/Drupal/views/Plugins/views/filter/ManyToOne.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugins\views\filter; +use Drupal\Core\Annotation\Plugin; + /** * Complex filter to handle filtering for many to one relationships, * such as terms (many terms per node) or roles (many roles per user). @@ -17,6 +19,12 @@ * * @ingroup views_filter_handlers */ + +/** + * @plugin( + * plugin_id = "many_to_one" + * ) + */ class ManyToOne extends InOperator { /** * @var views_many_to_one_helper diff --git a/lib/Drupal/views/Plugins/views/query/Sql.php b/lib/Drupal/views/Plugins/views/query/Sql.php index 4595183bf951..3f3d501af635 100644 --- a/lib/Drupal/views/Plugins/views/query/Sql.php +++ b/lib/Drupal/views/Plugins/views/query/Sql.php @@ -1532,7 +1532,7 @@ function get_aggregation_info() { 'handler' => array( 'argument' => 'views_handler_argument_group_by_numeric', 'field' => 'views_handler_field_numeric', - 'filter' => 'views_handler_filter_group_by_numeric', + 'filter' => 'groupby_numeric', 'sort' => 'groupby_numeric', ), ), @@ -1542,7 +1542,7 @@ function get_aggregation_info() { 'handler' => array( 'argument' => 'views_handler_argument_group_by_numeric', 'field' => 'views_handler_field_numeric', - 'filter' => 'views_handler_filter_group_by_numeric', + 'filter' => 'groupby_numeric', 'sort' => 'groupby_numeric', ), ), @@ -1551,7 +1551,7 @@ function get_aggregation_info() { 'method' => 'views_query_default_aggregation_method_simple', 'handler' => array( 'argument' => 'views_handler_argument_group_by_numeric', - 'filter' => 'views_handler_filter_group_by_numeric', + 'filter' => 'groupby_numeric', 'sort' => 'groupby_numeric', ), ), @@ -1560,7 +1560,7 @@ function get_aggregation_info() { 'method' => 'views_query_default_aggregation_method_simple', 'handler' => array( 'argument' => 'views_handler_argument_group_by_numeric', - 'filter' => 'views_handler_filter_group_by_numeric', + 'filter' => 'groupby_numeric', 'sort' => 'groupby_numeric', ), ), @@ -1569,7 +1569,7 @@ function get_aggregation_info() { 'method' => 'views_query_default_aggregation_method_simple', 'handler' => array( 'argument' => 'views_handler_argument_group_by_numeric', - 'filter' => 'views_handler_filter_group_by_numeric', + 'filter' => 'groupby_numeric', 'sort' => 'groupby_numeric', ), ), @@ -1578,7 +1578,7 @@ function get_aggregation_info() { 'method' => 'views_query_default_aggregation_method_simple', 'handler' => array( 'argument' => 'views_handler_argument_group_by_numeric', - 'filter' => 'views_handler_filter_group_by_numeric', + 'filter' => 'groupby_numeric', 'sort' => 'groupby_numeric', ), ), @@ -1587,7 +1587,7 @@ function get_aggregation_info() { 'method' => 'views_query_default_aggregation_method_simple', 'handler' => array( 'argument' => 'views_handler_argument_group_by_numeric', - 'filter' => 'views_handler_filter_group_by_numeric', + 'filter' => 'groupby_numeric', 'sort' => 'groupby_numeric', ), ) diff --git a/modules/comment.views.inc b/modules/comment.views.inc index b6dec9876419..c16f1cc72301 100644 --- a/modules/comment.views.inc +++ b/modules/comment.views.inc @@ -279,7 +279,7 @@ function comment_views_data() { ), ), 'filter' => array( - 'handler' => 'views_handler_filter_boolean_operator', + 'plugin_id' => 'boolean', 'label' => t('Approved comment'), 'type' => 'yes-no', ), diff --git a/modules/locale.views.inc b/modules/locale.views.inc index e27b8df5a56e..a12a4863dfd5 100644 --- a/modules/locale.views.inc +++ b/modules/locale.views.inc @@ -184,7 +184,7 @@ function locale_views_data() { 'click sortable' => TRUE, ), 'filter' => array( - 'handler' => 'views_handler_filter_boolean_operator', + 'plugin_id' => 'boolean', 'label' => t('Plural'), 'type' => 'yes-no', ), diff --git a/modules/node.views.inc b/modules/node.views.inc index 09703ea81391..d83a0859fabf 100644 --- a/modules/node.views.inc +++ b/modules/node.views.inc @@ -105,7 +105,7 @@ function node_views_data() { 'plugin_id' => 'date' ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\Date', + 'plugin_id' => 'date', ), ); @@ -121,7 +121,7 @@ function node_views_data() { 'plugin_id' => 'date' ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\Date', + 'plugin_id' => 'date', ), ); @@ -156,7 +156,7 @@ function node_views_data() { ), ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\BooleanOperator', + 'plugin_id' => 'boolean', 'label' => t('Published'), 'type' => 'yes-no', 'use equal' => TRUE, // Use status = 1 instead of status <> 0 in WHERE statment @@ -189,7 +189,7 @@ function node_views_data() { ), ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\BooleanOperator', + 'plugin_id' => 'boolean', 'label' => t('Promoted to front page'), 'type' => 'yes-no', ), @@ -211,7 +211,7 @@ function node_views_data() { ), ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\BooleanOperator', + 'plugin_id' => 'boolean', 'label' => t('Sticky'), 'type' => 'yes-no', ), @@ -535,7 +535,7 @@ function node_views_data() { 'plugin_id' => 'date' ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\Date', + 'plugin_id' => 'date', ), ); diff --git a/modules/poll.views.inc b/modules/poll.views.inc index d3fd76adca89..4ec5bb8e2ae2 100644 --- a/modules/poll.views.inc +++ b/modules/poll.views.inc @@ -34,7 +34,7 @@ function poll_views_data() { 'click sortable' => TRUE, ), 'filter' => array( - 'handler' => 'views_handler_filter_boolean_operator', + 'plugin_id' => 'boolean', 'label' => t('Active'), 'type' => 'yes-no', ), diff --git a/modules/search.views.inc b/modules/search.views.inc index ffde9af21b6b..32b7549a7e57 100644 --- a/modules/search.views.inc +++ b/modules/search.views.inc @@ -89,7 +89,7 @@ function search_views_data() { 'handler' => 'views_handler_argument_node_nid', ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\Equality', + 'plugin_id' => 'equality', ), ); @@ -107,7 +107,7 @@ function search_views_data() { 'handler' => 'views_handler_argument_node_nid', ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\Equality', + 'plugin_id' => 'equality', ), ); diff --git a/modules/statistics.views.inc b/modules/statistics.views.inc index 1b9cf2b006f9..8679efba9896 100644 --- a/modules/statistics.views.inc +++ b/modules/statistics.views.inc @@ -70,7 +70,7 @@ function statistics_views_data() { 'click sortable' => TRUE, ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\Date', + 'plugin_id' => 'date', ), 'sort' => array( 'plugin_id' => 'standard', @@ -254,7 +254,7 @@ function statistics_views_data() { 'plugin_id' => 'standard', ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\Date', + 'plugin_id' => 'date', ), ); diff --git a/modules/system.views.inc b/modules/system.views.inc index 4626fa68a793..f70a77fd2be4 100644 --- a/modules/system.views.inc +++ b/modules/system.views.inc @@ -163,7 +163,7 @@ function system_views_data() { 'plugin_id' => 'date' ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\Date', + 'plugin_id' => 'date', ), ); @@ -535,7 +535,7 @@ function system_views_data() { 'name field' => 'status', // the field to display in the summary. ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\BooleanOperator', + 'plugin_id' => 'boolean', ), 'sort' => array( 'plugin_id' => 'standard', diff --git a/modules/translation.views.inc b/modules/translation.views.inc index cb90205bf274..116174384bb7 100644 --- a/modules/translation.views.inc +++ b/modules/translation.views.inc @@ -98,7 +98,7 @@ function translation_views_data_alter(&$data) { 'click sortable' => TRUE, ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\BooleanOperator', + 'plugin_id' => 'boolean', 'label' => t('Outdated'), 'type' => 'yes-no', ), diff --git a/modules/user.views.inc b/modules/user.views.inc index 54ad20522b3f..652df3ab5e00 100644 --- a/modules/user.views.inc +++ b/modules/user.views.inc @@ -183,7 +183,7 @@ function user_views_data() { 'plugin_id' => 'standard', ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\BooleanOperator', + 'plugin_id' => 'boolean', 'label' => t('Has Avatar'), 'type' => 'yes-no', ), @@ -210,7 +210,7 @@ function user_views_data() { 'plugin_id' => 'date' ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\Date', + 'plugin_id' => 'date', ), ); @@ -281,7 +281,7 @@ function user_views_data() { 'plugin_id' => 'date' ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\Date', + 'plugin_id' => 'date', ), ); @@ -297,7 +297,7 @@ function user_views_data() { 'plugin_id' => 'date' ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\Date', + 'plugin_id' => 'date', ), ); @@ -314,7 +314,7 @@ function user_views_data() { ), ), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\BooleanOperator', + 'plugin_id' => 'boolean', 'label' => t('Active'), 'type' => 'yes-no', ), diff --git a/modules/views.views.inc b/modules/views.views.inc index a474da19c503..04ad7ce5e241 100644 --- a/modules/views.views.inc +++ b/modules/views.views.inc @@ -95,7 +95,7 @@ function views_views_data() { 'title' => t('Combine fields filter'), 'help' => t('Combine two fields together and search by them.'), 'filter' => array( - 'handler' => 'Drupal\views\Plugins\views\filter\Combine', + 'plugin_id' => 'combine', ), ); diff --git a/views.api.php b/views.api.php index 92f138a5970d..6a0eef2eb958 100644 --- a/views.api.php +++ b/views.api.php @@ -423,7 +423,7 @@ function hook_views_data() { 'click sortable' => TRUE, ), 'filter' => array( - 'handler' => 'views_handler_filter_boolean_operator', + 'plugin_id' => 'boolean', // Note that you can override the field-wide label: 'label' => t('Published'), // This setting is used by the boolean filter handler, as possible option. -- GitLab