Commit cabe4b19 authored by dawehner's avatar dawehner Committed by tim.plunkett

Introduce a handler base plugin

parent be8fab2f
......@@ -70,7 +70,8 @@ function _views_create_handler($definition, $type = 'handler', $handler_type = N
$handler = new $definition['override handler'];
}
else {
$handler = new $definition['handler'];
// @todo: $definition['handler'] is kind of a bad.
$handler = new $definition['handler']($definition, $definition['handler']);
}
$handler->set_definition($definition);
......
......@@ -268,7 +268,7 @@ function views_views_plugins() {
'title' => t('SQL Query'),
'help' => t('Query will be generated and run using the Drupal database API.'),
'class' => 'views_plugin_query_default',
'class' => 'Drupal\views\Plugins\views\query\SqlQuery',
'class' => 'Drupal\views\Plugins\views\query\Sql',
),
),
'cache' => array(
......
......@@ -8,6 +8,7 @@
namespace Drupal\views\Plugins\views\area;
use Drupal\views\Plugins\views\Plugin;
use Drupal\views\Plugins\views\Handler;
/**
* @defgroup views_area_handlers Views area handlers
......@@ -21,7 +22,7 @@
*
* @ingroup views_area_handlers
*/
class AreaPluginBase extends Plugin {
class AreaPluginBase extends Handler {
/**
* Get this field's label.
*/
......
......@@ -7,7 +7,8 @@
namespace Drupal\views\Plugins\views\argument;
use Drupal\views\Plugins\Plugin;
use Drupal\views\Plugins\views\Plugin;
use Drupal\views\Plugins\views\Handler;
/**
* @defgroup views_argument_handlers Views argument handlers
......@@ -39,7 +40,7 @@
*
* @ingroup views_argument_handlers
*/
class ArgumentPluginBase extends Plugin {
class ArgumentPluginBase extends Handler {
var $validator = NULL;
var $argument = NULL;
......
......@@ -9,7 +9,7 @@
use Drupal\views\View;
use Drupal\views\Plugins\views\Plugin;
use Drupal\views\Plugins\views\query\QueryPluginType;
use Drupal\views\Plugins\Type\QueryPluginManager;
/**
* @defgroup views_display_plugins Views display plugins
......@@ -881,6 +881,10 @@ function get_plugin($type = 'style', $name = NULL) {
// access & cache store their options as siblings with the
// type; all others use an 'options' array.
if ($type != 'access' && $type != 'cache') {
if (!isset($options['options'])) {
// debug($type);
// debug($options);
}
$options = $options['options'];
}
}
......@@ -889,7 +893,7 @@ function get_plugin($type = 'style', $name = NULL) {
$plugin = views_get_plugin($type, $name);
}
else {
$plugin_type = new QueryPluginType();
$plugin_type = new QueryPluginManager();
$plugin = $plugin_type->createInstance($name);
}
......
......@@ -8,6 +8,7 @@
namespace Drupal\views\Plugins\views\field;
use Drupal\views\Plugins\views\Plugin;
use Drupal\views\Plugins\views\Handler;
/**
* @defgroup views_field_handlers Views field handlers
......@@ -46,7 +47,7 @@
*
* @ingroup views_field_handlers
*/
class FieldPluginBase extends Plugin {
class FieldPluginBase extends Handler {
var $field_alias = 'unknown';
var $aliases = array();
......@@ -1624,7 +1625,7 @@ function ui_name($short = FALSE) {
*
* @ingroup views_field_handlers
*/
class views_handler_field_broken extends views_handler_field {
class views_handler_field_broken extends FieldPluginBase {
function ui_name($short = FALSE) {
return t('Broken/missing handler');
}
......@@ -1648,7 +1649,7 @@ function broken() { return TRUE; }
*
* @ingroup views_field_handlers
*/
class views_handler_field_file_size extends views_handler_field {
class views_handler_field_file_size extends FieldPluginBase {
function option_definition() {
$options = parent::option_definition();
......@@ -1691,7 +1692,7 @@ function render($values) {
*
* @ingroup views_field_handlers
*/
class views_handler_field_xss extends views_handler_field {
class views_handler_field_xss extends FieldPluginBase {
function render($values) {
$value = $this->get_value($values);
return $this->sanitize_value($value, 'xss');
......
......@@ -5,6 +5,8 @@
* Contains the basic 'node' field handler.
*/
use Drupal\views\Plugins\views\field\FieldPluginBase;
/**
* Field handler to provide simple renderer that allows linking to a node.
* Definition terms:
......@@ -12,7 +14,7 @@
*
* @ingroup views_field_handlers
*/
class views_handler_field_node extends views_handler_field {
class views_handler_field_node extends FieldPluginBase {
function init(&$view, &$options) {
parent::init($view, $options);
......
......@@ -1364,18 +1364,40 @@ function views_get_plugin($type, $plugin, $reset = FALSE) {
*/
function views_get_plugin_manager($type) {
switch ($type) {
case 'style':
$manager = new StylePluginManager();
break;
case 'display':
$manager = new DisplayPluginManager();
break;
case 'localization':
$manager = new LocalizationPluginManager();
case 'style':
$manager = new StylePluginManager();
break;
case 'row':
$manager = new RowPluginManager();
break;
case 'argument default':
$manager = new ArgumentDefaultPluginManager();
break;
case 'argument validator':
$manager = new ArgumentValidatorPluginManager();
break;
case 'access':
$manager = new AccessPluginManager();
break;
case 'query':
$manager = new QueryPluginManager();
break;
case 'cache':
$manager = new CachePluginManager();
break;
// @todo: find out whether to use underscores or spaces.
case 'exposed_form':
$manager = new ExposedFormPluginManager();
break;
case 'pager':
$manager = new PagerPluginManager();
break;
case 'localization':
$manager = new LocalizationPluginManager();
break;
}
return $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