From e2daf79ce8b2a90157d16eae8bdfc7ccbe31069c Mon Sep 17 00:00:00 2001 From: Daniel Wehner <daniel.wehner@erdfisch.de> Date: Sat, 28 Jul 2012 10:11:01 -0500 Subject: [PATCH] Convert broken handlers to PSR0 --- includes/handlers.inc | 2 +- lib/Drupal/views/Plugins/views/Plugin.php | 1 - .../Plugins/views/area/AreaPluginBase.php | 26 ------------ .../views/Plugins/views/area/Broken.php | 41 +++++++++++++++++++ .../views/argument/ArgumentPluginBase.php | 24 ----------- .../views/Plugins/views/argument/Broken.php | 40 ++++++++++++++++++ .../views/Plugins/views/field/Broken.php | 40 ++++++++++++++++++ .../Plugins/views/field/FieldPluginBase.php | 25 ----------- .../views/Plugins/views/filter/Broken.php | 40 ++++++++++++++++++ .../Plugins/views/filter/FilterPluginBase.php | 26 ------------ .../views/Plugins/views/sort/Broken.php | 40 ++++++++++++++++++ .../Plugins/views/sort/SortPluginBase.php | 31 -------------- views.module | 20 +++++---- 13 files changed, 213 insertions(+), 143 deletions(-) create mode 100644 lib/Drupal/views/Plugins/views/area/Broken.php create mode 100644 lib/Drupal/views/Plugins/views/argument/Broken.php create mode 100644 lib/Drupal/views/Plugins/views/field/Broken.php create mode 100644 lib/Drupal/views/Plugins/views/filter/Broken.php create mode 100644 lib/Drupal/views/Plugins/views/sort/Broken.php diff --git a/includes/handlers.inc b/includes/handlers.inc index 3bc656f17aaa..749d4a819245 100644 --- a/includes/handlers.inc +++ b/includes/handlers.inc @@ -39,7 +39,7 @@ function _views_create_plugin($type, $plugin_id, $definition) { * Instantiate and construct a new handler */ function _views_create_handler($definition, $type = 'handler', $handler_type = NULL) { - if ($definition['plugin_id']) { + if (!empty($definition['plugin_id'])) { $manager = views_get_plugin_manager($handler_type); $handler = $manager->createInstance($definition['plugin_id']); } diff --git a/lib/Drupal/views/Plugins/views/Plugin.php b/lib/Drupal/views/Plugins/views/Plugin.php index f19a74ddfae0..60a9c9a7aa0e 100644 --- a/lib/Drupal/views/Plugins/views/Plugin.php +++ b/lib/Drupal/views/Plugins/views/Plugin.php @@ -9,7 +9,6 @@ use Drupal\views\ViewsObject; use Drupal\Component\Plugin\PluginBase; -use Drupal\views\Plugin\PluginInterface; abstract class Plugin extends PluginBase { public function __construct(array $configuration, $plugin_id) { diff --git a/lib/Drupal/views/Plugins/views/area/AreaPluginBase.php b/lib/Drupal/views/Plugins/views/area/AreaPluginBase.php index 20c1929b7340..044fc5e9df4a 100644 --- a/lib/Drupal/views/Plugins/views/area/AreaPluginBase.php +++ b/lib/Drupal/views/Plugins/views/area/AreaPluginBase.php @@ -93,32 +93,6 @@ function use_group_by() { } } -/** - * A special handler to take the place of missing or broken handlers. - * - * @ingroup views_area_handlers - */ -class views_handler_area_broken extends AreaPluginBase { - function ui_name($short = FALSE) { - return t('Broken/missing handler'); - } - - function ensure_my_table() { /* No table to ensure! */ } - function query($group_by = FALSE) { /* No query to run */ } - function render($empty = FALSE) { return ''; } - function options_form(&$form, &$form_state) { - $form['markup'] = array( - '#prefix' => '<div class="form-item description">', - '#value' => t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.'), - ); - } - - /** - * Determine if the handler is considered 'broken' - */ - function broken() { return TRUE; } -} - /** * @} */ diff --git a/lib/Drupal/views/Plugins/views/area/Broken.php b/lib/Drupal/views/Plugins/views/area/Broken.php new file mode 100644 index 000000000000..20ce56c62661 --- /dev/null +++ b/lib/Drupal/views/Plugins/views/area/Broken.php @@ -0,0 +1,41 @@ +<?php + +/** + * @file + * Definition of Drupal\views\Plugins\views\sort\Broken + */ + +namespace Drupal\views\Plugins\views\area; + +use Drupal\Core\Annotation\Plugin; + +/** + * A special handler to take the place of missing or broken handlers. + * + * @ingroup views_area_handlers + */ + +/** + * @Plugin( + * plugin_id = "broken" + * ) + */ +class Broken extends AreaPluginBase { + function ui_name($short = FALSE) { + return t('Broken/missing handler'); + } + + function ensure_my_table() { /* No table to ensure! */ } + function query($group_by = FALSE) { /* No query to run */ } + function render($empty = FALSE) { return ''; } + function options_form(&$form, &$form_state) { + $form['markup'] = array( + '#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>', + ); + } + + /** + * Determine if the handler is considered 'broken' + */ + function broken() { return TRUE; } +} diff --git a/lib/Drupal/views/Plugins/views/argument/ArgumentPluginBase.php b/lib/Drupal/views/Plugins/views/argument/ArgumentPluginBase.php index 570cbe12dea2..41662bf28f68 100644 --- a/lib/Drupal/views/Plugins/views/argument/ArgumentPluginBase.php +++ b/lib/Drupal/views/Plugins/views/argument/ArgumentPluginBase.php @@ -1245,30 +1245,6 @@ function get_sort_name() { } -/** - * A special handler to take the place of missing or broken handlers. - * - * @ingroup views_argument_handlers - */ -class views_handler_argument_broken extends ArgumentPluginBase { - function ui_name($short = FALSE) { - return t('Broken/missing handler'); - } - - function ensure_my_table() { /* No table to ensure! */ } - function query($group_by = FALSE) { /* No query to run */ } - function options_form(&$form, &$form_state) { - $form['markup'] = array( - '#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>', - ); - } - - /** - * Determine if the handler is considered 'broken' - */ - function broken() { return TRUE; } -} - /** * @} */ diff --git a/lib/Drupal/views/Plugins/views/argument/Broken.php b/lib/Drupal/views/Plugins/views/argument/Broken.php new file mode 100644 index 000000000000..3873c9514593 --- /dev/null +++ b/lib/Drupal/views/Plugins/views/argument/Broken.php @@ -0,0 +1,40 @@ +<?php + +/** + * @file + * Definition of Drupal\views\Plugins\views\sort\Broken + */ + +namespace Drupal\views\Plugins\views\argument; + +use Drupal\Core\Annotation\Plugin; + +/** + * A special handler to take the place of missing or broken handlers. + * + * @ingroup views_argument_handlers + */ + +/** + * @Plugin( + * plugin_id = "broken" + * ) + */ +class Broken extends ArgumentPluginBase { + function ui_name($short = FALSE) { + return t('Broken/missing handler'); + } + + function ensure_my_table() { /* No table to ensure! */ } + function query($group_by = FALSE) { /* No query to run */ } + function options_form(&$form, &$form_state) { + $form['markup'] = array( + '#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>', + ); + } + + /** + * Determine if the handler is considered 'broken' + */ + function broken() { return TRUE; } +} diff --git a/lib/Drupal/views/Plugins/views/field/Broken.php b/lib/Drupal/views/Plugins/views/field/Broken.php new file mode 100644 index 000000000000..1ca24abebf13 --- /dev/null +++ b/lib/Drupal/views/Plugins/views/field/Broken.php @@ -0,0 +1,40 @@ +<?php + +/** + * @file + * Definition of Drupal\views\Plugins\views\sort\Broken + */ + +namespace Drupal\views\Plugins\views\field; + +use Drupal\Core\Annotation\Plugin; + +/** + * A special handler to take the place of missing or broken handlers. + * + * @ingroup views_field_handlers + */ + +/** + * @Plugin( + * plugin_id = "broken" + * ) + */ +class Broken extends FieldPluginBase { + function ui_name($short = FALSE) { + return t('Broken/missing handler'); + } + + function ensure_my_table() { /* No table to ensure! */ } + function query($group_by = FALSE) { /* No query to run */ } + function options_form(&$form, &$form_state) { + $form['markup'] = array( + '#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>', + ); + } + + /** + * Determine if the handler is considered 'broken' + */ + function broken() { return TRUE; } +} diff --git a/lib/Drupal/views/Plugins/views/field/FieldPluginBase.php b/lib/Drupal/views/Plugins/views/field/FieldPluginBase.php index 4dc3a5763c2f..dce63a3135c2 100644 --- a/lib/Drupal/views/Plugins/views/field/FieldPluginBase.php +++ b/lib/Drupal/views/Plugins/views/field/FieldPluginBase.php @@ -1620,31 +1620,6 @@ function ui_name($short = FALSE) { } -/** - * A special handler to take the place of missing or broken handlers. - * - * @ingroup views_field_handlers - */ -class views_handler_field_broken extends FieldPluginBase { - function ui_name($short = FALSE) { - return t('Broken/missing handler'); - } - - function ensure_my_table() { /* No table to ensure! */ } - function query($group_by = FALSE) { /* No query to run */ } - function options_form(&$form, &$form_state) { - $form['markup'] = array( - '#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>', - ); - } - - /** - * Determine if the handler is considered 'broken' - */ - function broken() { return TRUE; } -} - - /** * @} */ diff --git a/lib/Drupal/views/Plugins/views/filter/Broken.php b/lib/Drupal/views/Plugins/views/filter/Broken.php new file mode 100644 index 000000000000..113e5b6e8ae5 --- /dev/null +++ b/lib/Drupal/views/Plugins/views/filter/Broken.php @@ -0,0 +1,40 @@ +<?php + +/** + * @file + * Definition of Drupal\views\Plugins\views\sort\Broken + */ + +namespace Drupal\views\Plugins\views\filter; + +use Drupal\Core\Annotation\Plugin; + +/** + * A special handler to take the place of missing or broken handlers. + * + * @ingroup views_filter_handlers + */ + +/** + * @Plugin( + * plugin_id = "broken" + * ) + */ +class Broken extends FilterPluginBase { + function ui_name($short = FALSE) { + return t('Broken/missing handler'); + } + + function ensure_my_table() { /* No table to ensure! */ } + function query($group_by = FALSE) { /* No query to run */ } + function options_form(&$form, &$form_state) { + $form['markup'] = array( + '#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>', + ); + } + + /** + * Determine if the handler is considered 'broken' + */ + function broken() { return TRUE; } +} diff --git a/lib/Drupal/views/Plugins/views/filter/FilterPluginBase.php b/lib/Drupal/views/Plugins/views/filter/FilterPluginBase.php index dddfb55d7b47..7311213c59f0 100644 --- a/lib/Drupal/views/Plugins/views/filter/FilterPluginBase.php +++ b/lib/Drupal/views/Plugins/views/filter/FilterPluginBase.php @@ -718,32 +718,6 @@ function can_group() { } } - -/** - * A special handler to take the place of missing or broken handlers. - * - * @ingroup views_filter_handlers - */ -class views_handler_filter_broken extends FilterPluginBase { - function ui_name($short = FALSE) { - return t('Broken/missing handler'); - } - - function ensure_my_table() { /* No table to ensure! */ } - function query($group_by = FALSE) { /* No query to run */ } - function options_form(&$form, &$form_state) { - $form['markup'] = array( - '#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>', - ); - } - - /** - * Determine if the handler is considered 'broken' - */ - function broken() { return TRUE; } -} - - /** * @} */ diff --git a/lib/Drupal/views/Plugins/views/sort/Broken.php b/lib/Drupal/views/Plugins/views/sort/Broken.php new file mode 100644 index 000000000000..0aa29ae8006c --- /dev/null +++ b/lib/Drupal/views/Plugins/views/sort/Broken.php @@ -0,0 +1,40 @@ +<?php + +/** + * @file + * Definition of Drupal\views\Plugins\views\sort\Broken + */ + +namespace Drupal\views\Plugins\views\sort; + +use Drupal\Core\Annotation\Plugin; + +/** + * A special handler to take the place of missing or broken handlers. + * + * @ingroup views_sort_handlers + */ + +/** + * @Plugin( + * plugin_id = "broken" + * ) + */ +class Broken extends SortPluginBase { + function ui_name($short = FALSE) { + return t('Broken/missing handler'); + } + + function ensure_my_table() { /* No table to ensure! */ } + function query($group_by = FALSE) { /* No query to run */ } + function options_form(&$form, &$form_state) { + $form['markup'] = array( + '#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>', + ); + } + + /** + * Determine if the handler is considered 'broken' + */ + function broken() { return TRUE; } +} diff --git a/lib/Drupal/views/Plugins/views/sort/SortPluginBase.php b/lib/Drupal/views/Plugins/views/sort/SortPluginBase.php index 347084da0b93..da5221e74b8b 100644 --- a/lib/Drupal/views/Plugins/views/sort/SortPluginBase.php +++ b/lib/Drupal/views/Plugins/views/sort/SortPluginBase.php @@ -222,37 +222,6 @@ function expose_options() { } } -/** - * A special handler to take the place of missing or broken handlers. - * - * @ingroup views_sort_handlers - */ - -/** - * @Plugin( - * plugin_id = "broken" - * ) - */ -class views_handler_sort_broken extends SortPluginBase { - function ui_name($short = FALSE) { - return t('Broken/missing handler'); - } - - function ensure_my_table() { /* No table to ensure! */ } - function query($group_by = FALSE) { /* No query to run */ } - function options_form(&$form, &$form_state) { - $form['markup'] = array( - '#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>', - ); - } - - /** - * Determine if the handler is considered 'broken' - */ - function broken() { return TRUE; } -} - - /** * @} */ diff --git a/views.module b/views.module index 247504cacad9..19e54fd3a4b8 100644 --- a/views.module +++ b/views.module @@ -1273,13 +1273,10 @@ function views_get_handler($table, $field, $key, $override = NULL) { return $handler; } - // Set up a default handler: - if (empty($data[$field][$key]['handler'])) { - $data[$field][$key]['handler'] = 'views_handler_' . $key; - } - - if ($override) { - $data[$field][$key]['override handler'] = $override; + // @fixme: temporary. + // Set up a default handler, if both handler and plugin_id is not specified. + if (empty($data[$field][$key]['handler']) && empty($data[$field][$key]['plugin_id'])) { + $data[$field][$key]['plugin_id'] = 'standard'; } $handler = _views_prepare_handler($data[$field][$key], $data, $field, $key); @@ -1293,7 +1290,7 @@ function views_get_handler($table, $field, $key, $override = NULL) { vpr("Missing handler: @table @field @key", array('@table' => $table, '@field' => $field, '@key' => $key)); $broken = array( 'title' => t('Broken handler @table.@field', array('@table' => $table, '@field' => $field)), - 'handler' => 'views_handler_' . $key . '_broken', + 'plugin_id' => 'broken', 'table' => $table, 'field' => $field, ); @@ -1416,8 +1413,13 @@ function views_get_plugin_manager($type) { case 'localization': $manager = new LocalizationPluginManager(); break; + case 'field': + case 'filter': + case 'argument': + case 'area': case 'sort': - $manager = new HandlerPluginManager('sort'); + case 'relationship': + $manager = new HandlerPluginManager($type); break; } -- GitLab