Commit 9bc9242d authored by tim.plunkett's avatar tim.plunkett

Issue #1734904 by tim.plunkett: Clean up plugins.

parent e5a4ab8a
......@@ -137,4 +137,5 @@ public function formatMessages(array $messages) {
static function formatMessage($message, $type = 'error') {
return array('message' => $message, 'type' => $type);
}
}
......@@ -59,14 +59,20 @@
* - - numeric: If true, the value will not be surrounded in quotes.
* - - extra type: How all the extras will be combined. Either AND or OR. Defaults to AND.
*/
class Join {
var $table = NULL;
var $left_table = NULL;
var $left_field = NULL;
var $field = NULL;
var $extra = NULL;
var $type = NULL;
var $definition = array();
/**
......@@ -204,6 +210,7 @@ function build_join($select_query, $table, $view_query) {
$select_query->addJoin($this->type, $right_table, $table['alias'], $condition, $arguments);
}
}
/**
......
......@@ -19,6 +19,7 @@
* - left_query: The subquery to use in the left side of the join clause.
*/
class JoinSubquery extends Join {
function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT') {
parent::construct($table, $left_table, $left_field, $field, $extra, $type);
$this->left_query = $this->definition['left_query'];
......@@ -99,4 +100,5 @@ function build_join($select_query, $table, $view_query) {
$select_query->addJoin($this->type, $right_table, $table['alias'], $condition, $arguments);
}
}
......@@ -13,6 +13,7 @@
* Discovery interface which supports the hook_views_plugins mechanism.
*/
class ViewsDiscovery extends AnnotatedClassDiscovery {
public function getDefinitions() {
$definitions = parent::getDefinitions();
foreach ($definitions as $definition) {
......@@ -51,4 +52,5 @@ public function getDefinitions() {
return $definitions;
}
}
......@@ -13,6 +13,7 @@
use Drupal\Core\Plugin\Discovery\CacheDecorator;
class ViewsPluginManager extends PluginManagerBase {
/**
* The handler type of this plugin manager, for example filter or field.
*
......@@ -26,4 +27,5 @@ public function __construct($type) {
$this->discovery = new CacheDecorator(new ViewsDiscovery('views', $this->type), 'views:' . $this->type, 'cache');
$this->factory = new DefaultFactory($this->discovery);
}
}
......@@ -9,7 +9,8 @@
use Drupal\views\Plugin\views\Plugin;
use Drupal\views\View;
class Handler extends Plugin {
abstract class Handler extends Plugin {
/**
* Where the $query object will reside:
*
......@@ -603,4 +604,5 @@ function validate() { return array(); }
* a placeholder used when a handler can't be found.
*/
function broken() { }
}
......@@ -451,4 +451,5 @@ function plugin_title() {
}
return check_plain($this->definition['title']);
}
}
......@@ -21,6 +21,7 @@
* The base plugin to handle access control.
*/
abstract class AccessPluginBase extends Plugin {
/**
* Initialize the plugin.
*
......@@ -93,6 +94,7 @@ function get_access_callback() {
// default to no access control.
return TRUE;
}
}
/**
......
......@@ -14,9 +14,7 @@
* Access plugin that provides no access control at all.
*
* @ingroup views_access_plugins
*/
/**
*
* @Plugin(
* id = "none",
* title = @Translation("None"),
......@@ -25,7 +23,9 @@
* )
*/
class None extends AccessPluginBase {
function summary_title() {
return t('Unrestricted');
}
}
......@@ -14,9 +14,7 @@
* Access plugin that provides permission-based access control.
*
* @ingroup views_access_plugins
*/
/**
*
* @Plugin(
* id = "perm",
* title = @Translation("Permission"),
......@@ -26,6 +24,7 @@
* )
*/
class Permission extends AccessPluginBase {
function access($account) {
return views_check_perm($this->options['perm'], $account);
}
......@@ -74,4 +73,5 @@ function options_form(&$form, &$form_state) {
'#description' => t('Only users with the selected permission flag will be able to access this display. Note that users with "access all views" can see any view, regardless of other permissions.'),
);
}
}
......@@ -14,9 +14,7 @@
* Access plugin that provides role-based access control.
*
* @ingroup views_access_plugins
*/
/**
*
* @Plugin(
* id = "role",
* title = @Translation("Role"),
......@@ -26,6 +24,7 @@
* )
*/
class Role extends AccessPluginBase {
function access($account) {
return views_check_roles(array_filter($this->options['role']), $account);
}
......@@ -78,4 +77,5 @@ function options_submit(&$form, &$form_state) {
// I hate checkboxes.
$form_state['values']['access_options']['role'] = array_filter($form_state['values']['access_options']['role']);
}
}
......@@ -22,10 +22,7 @@
*
* @ingroup views_area_handlers
*/
/**
*/
class AreaPluginBase extends Handler {
abstract class AreaPluginBase extends Handler {
/**
* Overrides Handler::init().
......@@ -108,6 +105,7 @@ function render($empty = FALSE) {
function use_group_by() {
return FALSE;
}
}
/**
......
......@@ -13,14 +13,13 @@
* A special handler to take the place of missing or broken handlers.
*
* @ingroup views_area_handlers
*/
/**
*
* @Plugin(
* id = "broken"
* )
*/
class Broken extends AreaPluginBase {
function ui_name($short = FALSE) {
return t('Broken/missing handler');
}
......@@ -37,5 +36,8 @@ function options_form(&$form, &$form_state) {
/**
* Determine if the handler is considered 'broken'
*/
function broken() { return TRUE; }
function broken() {
return TRUE;
}
}
......@@ -13,9 +13,7 @@
* Views area handler to display some configurable result summary.
*
* @ingroup views_area_handlers
*/
/**
*
* @Plugin(
* id = "result"
* )
......@@ -103,4 +101,5 @@ function render($empty = FALSE) {
}
return $output;
}
}
......@@ -13,9 +13,7 @@
* Views area text handler.
*
* @ingroup views_area_handlers
*/
/**
*
* @Plugin(
* id = "text"
* )
......@@ -117,4 +115,5 @@ function render_textarea($value, $format) {
return check_markup($value, $format, '', FALSE);
}
}
}
......@@ -13,9 +13,7 @@
* Views area text handler.
*
* @ingroup views_area_handlers
*/
/**
*
* @Plugin(
* id = "text_custom"
* )
......
......@@ -13,9 +13,7 @@
* Views area handlers. Insert a view inside of an area.
*
* @ingroup views_area_handlers
*/
/**
*
* @Plugin(
* id = "view"
* )
......@@ -90,4 +88,5 @@ function render($empty = FALSE) {
}
return '';
}
}
......@@ -40,10 +40,7 @@
*
* @ingroup views_argument_handlers
*/
/**
*/
class ArgumentPluginBase extends Handler {
abstract class ArgumentPluginBase extends Handler {
var $validator = NULL;
var $argument = NULL;
......
......@@ -13,14 +13,13 @@
* A special handler to take the place of missing or broken handlers.
*
* @ingroup views_argument_handlers
*/
/**
*
* @Plugin(
* id = "broken"
* )
*/
class Broken extends ArgumentPluginBase {
function ui_name($short = FALSE) {
return t('Broken/missing handler');
}
......@@ -37,4 +36,5 @@ function options_form(&$form, &$form_state) {
* Determine if the handler is considered 'broken'
*/
function broken() { return TRUE; }
}
......@@ -26,9 +26,7 @@
* @see Drupal\views\ManyTonOneHelper
*
* @ingroup views_argument_handlers
*/
/**
*
* @Plugin(
* id = "date"
* )
......
......@@ -18,15 +18,15 @@
* - formula: The formula to use for this handler.
*
* @ingroup views_argument_handlers
*/
/**
*
* @Plugin(
* id = "formula"
* )
*/
class Formula extends ArgumentPluginBase {
var $formula = NULL;
/**
* Constructor
*/
......@@ -70,4 +70,5 @@ function query($group_by = FALSE) {
);
$this->query->add_where(0, $formula, $placeholders, 'formula');
}
}
......@@ -13,14 +13,13 @@
* Simple handler for arguments using group by.
*
* @ingroup views_argument_handlers
*/
/**
*
* @Plugin(
* id = "groupby_numeric"
* )
*/
class GroupByNumeric extends ArgumentPluginBase {
class GroupByNumeric extends ArgumentPluginBase {
function query($group_by = FALSE) {
$this->ensure_my_table();
$field = $this->get_field();
......@@ -36,4 +35,5 @@ function ui_name($short = FALSE) {
function get_sort_name() {
return t('Numerical', array(), array('context' => 'Sort order'));
}
}
......@@ -22,14 +22,13 @@
* a default argument can be provided or a summary can be shown.
*
* @ingroup views_argument_handlers
*/
/**
*
* @Plugin(
* id = "many_to_one"
* )
*/
class ManyToOne extends ArgumentPluginBase {
function init(&$view, &$options) {
parent::init($view, $options);
$this->helper = new ManyToOneHelper($this);
......@@ -193,4 +192,5 @@ function summary_argument($data) {
function title_query() {
return $this->value;
}
}
......@@ -13,14 +13,13 @@
* Argument handler that ignores the argument.
*
* @ingroup views_argument_handlers
*/
/**
*
* @Plugin(
* id = "null"
* )
*/
class Null extends ArgumentPluginBase {
function option_definition() {
$options = parent::option_definition();
$options['must_not_be'] = array('default' => FALSE, 'bool' => TRUE);
......@@ -74,4 +73,5 @@ function validate_argument_basic($arg) {
* from being changed in any way.
*/
function query($group_by = FALSE) {}
}
......@@ -14,14 +14,13 @@
* break_phrase.
*
* @ingroup views_argument_handlers
*/
/**
*
* @Plugin(
* id = "numeric"
* )
*/
class Numeric extends ArgumentPluginBase {
/**
* The operator used for the query: or|and.
* @var string
......@@ -123,4 +122,5 @@ function query($group_by = FALSE) {
function get_sort_name() {
return t('Numerical', array(), array('context' => 'Sort order'));
}
}
......@@ -15,14 +15,13 @@
* limits.
*
* @ingroup views_argument_handlers
*/
/**
*
* @Plugin(
* id = "string"
* )
*/
class String extends ArgumentPluginBase {
function init(&$view, &$options) {
parent::init($view, $options);
if (!empty($this->definition['many to one'])) {
......
......@@ -21,6 +21,7 @@
* The fixed argument default handler; also used as the base.
*/
abstract class ArgumentDefaultPluginBase extends Plugin {
/**
* Return the default argument.
*
......@@ -91,6 +92,7 @@ function check_access(&$form, $option_name) {
* views_plugin_argument_default_fixed for a good example of this method.
*/
function convert_options(&$options) { }
}
/**
......
......@@ -14,15 +14,14 @@
* The fixed argument default handler.
*
* @ingroup views_argument_default_plugins
*/
/**
*
* @Plugin(
* id = "fixed",
* title = @Translation("Fixed")
* )
*/
class Fixed extends ArgumentDefaultPluginBase {
function option_definition() {
$options = parent::option_definition();
$options['argument'] = array('default' => '');
......@@ -51,8 +50,5 @@ function convert_options(&$options) {
$options['argument'] = $this->argument->options['default_argument_fixed'];
}
}
}
/**
* @}
*/
}
......@@ -14,15 +14,14 @@
* Default argument plugin to provide a PHP code block.
*
* @ingroup views_argument_default_plugins
*/
/**
*
* @Plugin(
* id = "php",
* title = @Translation("PHP Code")
* )
*/
class Php extends ArgumentDefaultPluginBase {
function option_definition() {
$options = parent::option_definition();