Commit 2daec13e authored by tim.plunkett's avatar tim.plunkett Committed by tim.plunkett

Issue #1792454 by tim.plunkett: Add type hinting to function signatures for $view.

parent 28bdcca2
......@@ -793,7 +793,7 @@ function theme_views_ui_view_info($variables) {
/**
* Page to delete a view.
*/
function views_ui_break_lock_confirm($form, &$form_state, $view) {
function views_ui_break_lock_confirm($form, &$form_state, ViewExecutable $view) {
$form_state['view'] = &$view;
$form = array();
......@@ -912,7 +912,7 @@ function views_ui_build_preview($view, $display_id, $render = TRUE) {
*
* @see views_ui_ajax_get_form()
*/
function views_ui_edit_form($form, &$form_state, $view, $display_id = NULL) {
function views_ui_edit_form($form, &$form_state, ViewExecutable $view, $display_id = NULL) {
// Do not allow the form to be cached, because $form_state['view'] can become
// stale between page requests.
// See views_ui_ajax_get_form() for how this affects #ajax.
......@@ -1097,7 +1097,7 @@ function views_ui_edit_form($form, &$form_state, $view, $display_id = NULL) {
/**
* Provide the preview formulas and the preview output, too.
*/
function views_ui_preview_form($form, &$form_state, $view, $display_id = 'default') {
function views_ui_preview_form($form, &$form_state, ViewExecutable $view, $display_id = 'default') {
$form_state['no_cache'] = TRUE;
$form_state['view'] = $view;
......@@ -1672,7 +1672,7 @@ function views_ui_get_display_tab_details($view, $display) {
* This function might be more logical as a method on an object, if a suitable
* object emerges out of refactoring.
*/
function views_ui_edit_form_get_build_from_option($id, $option, $view, $display) {
function views_ui_edit_form_get_build_from_option($id, $option, ViewExecutable $view, $display) {
$option_build = array();
$option_build['#theme'] = 'views_ui_display_tab_setting';
......@@ -2100,7 +2100,7 @@ function views_ui_edit_view_form_delete($form, &$form_state) {
/**
* Add information about a section to a display.
*/
function views_ui_edit_form_get_bucket($type, $view, $display) {
function views_ui_edit_form_get_bucket($type, ViewExecutable $view, $display) {
$build = array(
'#theme_wrappers' => array('views_ui_display_tab_bucket'),
);
......@@ -2285,7 +2285,7 @@ function views_ui_edit_form_get_bucket($type, $view, $display) {
/**
* Regenerate the current tab for AJAX updates.
*/
function views_ui_regenerate_tab(&$view, &$output, $display_id) {
function views_ui_regenerate_tab(ViewExecutable $view, &$output, $display_id) {
if (!$view->setDisplay('default')) {
return;
}
......@@ -2674,7 +2674,7 @@ function views_ui_ajax_forms($key = NULL) {
* is the same as another. Since the arguments differ slightly
* we do a lot of spiffy concatenation here.
*/
function views_ui_build_identifier($key, $view, $display_id, $args) {
function views_ui_build_identifier($key, ViewExecutable $view, $display_id, $args) {
$form = views_ui_ajax_forms($key);
// Automatically remove the single-form cache if it exists and
// does not match the key.
......@@ -2691,7 +2691,7 @@ function views_ui_build_identifier($key, $view, $display_id, $args) {
* Build up a $form_state object suitable for use with drupal_build_form
* based on known information about a form.
*/
function views_ui_build_form_state($js, $key, &$view, $display_id, $args) {
function views_ui_build_form_state($js, $key, ViewExecutable $view, $display_id, $args) {
$form = views_ui_ajax_forms($key);
// Build up form state
$form_state = array(
......@@ -2729,7 +2729,7 @@ function views_ui_build_form_url($form_state) {
* Add another form to the stack; clicking 'apply' will go to this form
* rather than closing the ajax popup.
*/
function views_ui_add_form_to_stack($key, &$view, $display_id, $args, $top = FALSE, $rebuild_keys = FALSE) {
function views_ui_add_form_to_stack($key, ViewExecutable $view, $display_id, $args, $top = FALSE, $rebuild_keys = FALSE) {
if (empty($view->stack)) {
$view->stack = array();
}
......@@ -2773,7 +2773,7 @@ function views_ui_add_form_to_stack($key, &$view, $display_id, $args, $top = FAL
* We do this for consistency and to make it easy to chain forms
* together.
*/
function views_ui_ajax_form($js, $key, $view, $display_id = '') {
function views_ui_ajax_form($js, $key, ViewExecutable $view, $display_id = '') {
$form = views_ui_ajax_forms($key);
if (empty($form)) {
return MENU_NOT_FOUND;
......
......@@ -87,7 +87,7 @@ public function __construct(array $configuration, $plugin_id, DiscoveryInterface
* The item from the database; the actual contents of this will vary
* based upon the type of handler.
*/
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$display_id = $this->view->current_display;
......
......@@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\access;
use Drupal\views\Plugin\views\PluginBase;
use Drupal\views\ViewExecutable;
/**
* @defgroup views_access_plugins Views access plugins
......@@ -33,7 +34,7 @@ abstract class AccessPluginBase extends PluginBase {
* @param $display
* The display handler.
*/
public function init(&$view, &$display) {
public function init(ViewExecutable $view, &$display) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->displayHandler = &$display;
......
......@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\area;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\PluginBase;
use Drupal\views\Plugin\views\HandlerBase;
......@@ -30,7 +31,7 @@ abstract class AreaPluginBase extends HandlerBase {
* Make sure that no result area handlers are set to be shown when the result
* is empty.
*/
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
$this->setOptionDefaults($this->options, $this->defineOptions());
parent::init($view, $options);
if ($this->definition['plugin_type'] == 'empty') {
......
......@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\argument;
use Drupal\views\ViewExecutable;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\ManyToOneHelper;
......@@ -29,7 +30,7 @@
*/
class ManyToOne extends ArgumentPluginBase {
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
$this->helper = new ManyToOneHelper($this);
......
......@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\argument;
use Drupal\views\ViewExecutable;
use Drupal\views\ManyToOneHelper;
use Drupal\Core\Annotation\Plugin;
......@@ -22,7 +23,7 @@
*/
class String extends ArgumentPluginBase {
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
if (!empty($this->definition['many to one'])) {
$this->helper = new ManyToOneHelper($this);
......
......@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\argument_default;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\PluginBase;
/**
......@@ -33,7 +34,7 @@ function get_argument() { }
* Initialize this plugin with the view and the argument
* it is linked to.
*/
public function init(&$view, &$argument, $options) {
public function init(ViewExecutable $view, &$argument, $options) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->argument = &$argument;
......
......@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\argument_validator;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\PluginBase;
/**
......@@ -26,7 +27,7 @@ abstract class ArgumentValidatorPluginBase extends PluginBase {
* Initialize this plugin with the view and the argument
* it is linked to.
*/
public function init(&$view, &$argument, $options) {
public function init(ViewExecutable $view, &$argument, $options) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->argument = &$argument;
......
......@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\cache;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\PluginBase;
use Drupal\Core\Database\Query\Select;
......@@ -62,7 +63,7 @@ abstract class CachePluginBase extends PluginBase {
* @param $display
* The display handler.
*/
public function init(&$view, &$display) {
public function init(ViewExecutable $view, &$display) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->displayHandler = &$display;
......
......@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\display_extender;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\PluginBase;
use Drupal\Core\Annotation\Translation;
......@@ -17,7 +18,7 @@
*/
abstract class DisplayExtenderPluginBase extends PluginBase {
public function init(&$view, &$display) {
public function init(ViewExecutable $view, &$display) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = $view;
$this->display = $display;
......
......@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\exposed_form;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\PluginBase;
/**
......@@ -37,7 +38,7 @@ abstract class ExposedFormPluginBase extends PluginBase {
* @param $display
* The display handler.
*/
public function init(&$view, &$display, $options = array()) {
public function init(ViewExecutable $view, &$display, $options = array()) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->displayHandler = &$display;
......
......@@ -6,6 +6,8 @@
*/
namespace Drupal\views\Plugin\views\field;
use Drupal\views\ViewExecutable;
use Drupal\Core\Annotation\Plugin;
/**
......@@ -38,7 +40,7 @@ protected function defineOptions() {
return $options;
}
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
$default_formats = array(
......
......@@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\field;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\ViewExecutable;
/**
* A handler to run a field through check_markup, using a companion
......@@ -26,7 +27,7 @@
*/
class Markup extends FieldPluginBase {
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
$this->format = $this->definition['format'];
......
......@@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\filter;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\ViewExecutable;
/**
* A special handler to take the place of missing or broken handlers.
......@@ -24,7 +25,7 @@ public function adminLabel($short = FALSE) {
return t('Broken/missing handler');
}
public function init(&$view, &$options) { }
public function init(ViewExecutable $view, &$options) { }
public function defineOptions() { return array(); }
public function ensureMyTable() { /* No table to ensure! */ }
public function query($group_by = FALSE) { /* No query to run */ }
......
......@@ -9,6 +9,7 @@
use Drupal\views\Plugin\views\HandlerBase;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\ViewExecutable;
/**
* @defgroup views_filter_handlers Views filter handlers
......@@ -78,7 +79,7 @@ abstract class FilterPluginBase extends HandlerBase {
* This likely has to be overridden by filters which are more complex
* than simple operator/value.
*/
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
$this->operator = $this->options['operator'];
......
......@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\filter;
use Drupal\views\ViewExecutable;
use Drupal\views\ManyToOneHelper;
use Drupal\Core\Annotation\Plugin;
......@@ -33,7 +34,7 @@ class ManyToOne extends InOperator {
*/
var $helper = NULL;
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
$this->helper = new ManyToOneHelper($this);
}
......
......@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\pager;
use Drupal\views\ViewExecutable;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
......@@ -24,7 +25,7 @@
*/
class None extends PagerPluginBase {
public function init(&$view, &$display, $options = array()) {
public function init(ViewExecutable $view, &$display, $options = array()) {
parent::init($view, $display, $options);
// If the pager is set to none, then it should show all items.
......
......@@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\pager;
use Drupal\views\Plugin\views\PluginBase;
use Drupal\views\ViewExecutable;
/**
* @defgroup views_pager_plugins Views pager plugins
......@@ -42,7 +43,7 @@ abstract class PagerPluginBase extends PluginBase {
* @param $display
* The display handler.
*/
public function init(&$view, &$display, $options = array()) {
public function init(ViewExecutable $view, &$display, $options = array()) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->displayHandler = &$display;
......
......@@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\query;
use Drupal\views\Plugin\views\PluginBase;
use Drupal\views\ViewExecutable;
/**
* @todo.
......@@ -46,7 +47,7 @@ public function query($get_count = FALSE) { }
* @param view $view
* The view which is executed.
*/
function alter(&$view) { }
function alter(ViewExecutable $view) { }
/**
* Builds the necessary info to execute the query.
......@@ -54,7 +55,7 @@ function alter(&$view) { }
* @param view $view
* The view which is executed.
*/
function build(&$view) { }
function build(ViewExecutable $view) { }
/**
* Executes the query and fills the associated view object with according
......@@ -69,7 +70,7 @@ function build(&$view) { }
* @param view $view
* The view which is executed.
*/
function execute(&$view) { }
function execute(ViewExecutable $view) { }
/**
* Add a signature to the query, if such a thing is feasible.
......@@ -80,7 +81,7 @@ function execute(&$view) { }
* @param view $view
* The view which is executed.
*/
function add_signature(&$view) { }
function add_signature(ViewExecutable $view) { }
/**
* Get aggregation info for group by queries.
......
......@@ -12,6 +12,7 @@
use Drupal\views\Plugin\views\join\JoinPluginBase;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
use Drupal\views\ViewExecutable;
/**
* @todo.
......@@ -1402,7 +1403,7 @@ function get_where_args() {
/**
* Let modules modify the query just prior to finalizing it.
*/
function alter(&$view) {
function alter(ViewExecutable $view) {
foreach (module_implements('views_query_alter') as $module) {
$function = $module . '_views_query_alter';
$function($view, $this);
......@@ -1412,7 +1413,7 @@ function alter(&$view) {
/**
* Builds the necessary info to execute the query.
*/
function build(&$view) {
function build(ViewExecutable $view) {
// Make the query distinct if the option was set.
if (!empty($this->options['distinct'])) {
$this->set_distinct(TRUE);
......@@ -1437,7 +1438,7 @@ function build(&$view) {
* Values to set: $view->result, $view->total_rows, $view->execute_time,
* $view->current_page.
*/
function execute(&$view) {
function execute(ViewExecutable $view) {
$external = FALSE; // Whether this query will run against an external database.
$query = $view->build_info['query'];
$count_query = $view->build_info['count_query'];
......@@ -1646,7 +1647,7 @@ function load_entities(&$results) {
}
}
function add_signature(&$view) {
function add_signature(ViewExecutable $view) {
$view->query->add_field(NULL, "'" . $view->storage->name . ':' . $view->current_display . "'", 'view_name');
}
......
......@@ -8,7 +8,6 @@
namespace Drupal\views\Plugin\views\relationship;
use Drupal\Core\Database\Query\AlterableInterface;
use Drupal\views\ViewExecutable;
use Drupal\Core\Annotation\Plugin;
/**
......
......@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\relationship;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\HandlerBase;
use Drupal\views\Join;
use Drupal\Core\Annotation\Plugin;
......@@ -47,7 +48,7 @@ abstract class RelationshipPluginBase extends HandlerBase {
* Init handler to let relationships live on tables other than
* the table they operate on.
*/
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
$this->setOptionDefaults($this->options, $this->defineOptions());
parent::init($view, $options);
if (isset($this->definition['relationship table'])) {
......
......@@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\row;
use Drupal\views\Plugin\views\PluginBase;
use Drupal\views\ViewExecutable;
/**
* @defgroup views_row_plugins Views row plugins
......@@ -41,7 +42,7 @@ abstract class RowPluginBase extends PluginBase {
/**
* Initialize the row plugin.
*/
public function init(&$view, &$display, $options = NULL) {
public function init(ViewExecutable $view, &$display, $options = NULL) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->displayHandler = &$display;
......
......@@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\sort;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\ViewExecutable;
/**
* Handler for GROUP BY on simple numeric fields.
......@@ -18,7 +19,7 @@
*/
class GroupByNumeric extends SortPluginBase {
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
// Initialize the original handler.
......
......@@ -11,6 +11,7 @@
use Drupal\views\Plugin\views\wizard\WizardInterface;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
use Drupal\views\ViewExecutable;
/**
* @defgroup views_style_plugins Views style plugins
......@@ -89,7 +90,7 @@ abstract class StylePluginBase extends PluginBase {
* The style options might come externally as the style can be sourced
* from at least two locations. If it's not included, look on the display.
*/
public function init(&$view, &$display, $options = NULL) {
public function init(ViewExecutable $view, &$display, $options = NULL) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->displayHandler = &$display;
......
......@@ -7,6 +7,7 @@
namespace Views\comment\Plugin\views\field;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
......@@ -25,7 +26,7 @@ class Comment extends FieldPluginBase {
/**
* Override init function to provide generic option to link to comment.
*/
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
if (!empty($this->options['link_to_comment'])) {
$this->additional_fields['cid'] = 'cid';
......
......@@ -7,6 +7,7 @@
namespace Views\comment\Plugin\views\field;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
......@@ -25,7 +26,7 @@ class Username extends FieldPluginBase {
/**
* Override init function to add uid and homepage fields.
*/
public function init(&$view, &$data) {
public function init(ViewExecutable $view, &$data) {
parent::init($view, $data);
$this->additional_fields['uid'] = 'uid';
$this->additional_fields['homepage'] = 'homepage';
......
......@@ -7,6 +7,7 @@
namespace Views\field\Plugin\views\argument;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\argument\Numeric;
use Drupal\Core\Annotation\Plugin;
......@@ -30,7 +31,7 @@ class FieldList extends Numeric {
*/
var $allowed_values = NULL;
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
$field = field_info_field($this->definition['field_name']);
$this->allowed_values = options_allowed_values($field);
......
......@@ -7,6 +7,7 @@
namespace Views\field\Plugin\views\argument;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\argument\String;
use Drupal\Core\Annotation\Plugin;
......@@ -30,7 +31,7 @@ class ListString extends String {
*/
var $allowed_values = NULL;
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
$field = field_info_field($this->definition['field_name']);
$this->allowed_values = options_allowed_values($field);
......
......@@ -7,6 +7,7 @@
namespace Views\field\Plugin\views\field;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
......@@ -65,7 +66,7 @@ class Field extends FieldPluginBase {
*/
public $instance;
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
$this->field_info = $field = field_info_field($this->definition['field_name']);
......
......@@ -7,6 +7,7 @@
namespace Views\field\Plugin\views\relationship;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\relationship\RelationshipPluginBase;
use Drupal\Core\Annotation\Plugin;
......@@ -22,7 +23,7 @@
*/
class EntityReverse extends RelationshipPluginBase {
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
$this->field_info = field_info_field($this->definition['field_name']);
......
......@@ -7,6 +7,7 @@
namespace Views\file\Plugin\views\field;
use Drupal\views\ViewExecutable;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\field\FieldPluginBase;
......@@ -25,7 +26,7 @@ class File extends FieldPluginBase {
/**
* Constructor to provide additional field to add.
*/
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
if (!empty($options['link_to_file'])) {
$this->additional_fields['uri'] = 'uri';
......
......@@ -7,6 +7,7 @@
namespace Views\node\Plugin\views\field;
use Drupal\views\ViewExecutable;
use Views\node\Plugin\views\field\Node;
use Drupal\Core\Annotation\Plugin;
......@@ -25,7 +26,7 @@
*/
class HistoryUserTimestamp extends Node {
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
global $user;
if ($user->uid) {
......
......@@ -7,6 +7,7 @@
namespace Views\node\Plugin\views\field;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
......@@ -24,7 +25,7 @@
*/
class Node extends FieldPluginBase {
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
// Don't add the additional fields to groupby
if (!empty($this->options['link_to_node'])) {
......
......@@ -7,6 +7,7 @@
namespace Views\node\Plugin\views\field;
use Drupal\views\ViewExecutable;
use Views\node\Plugin\views\field\Node;
use Drupal\Core\Annotation\Plugin;
......@@ -22,7 +23,7 @@
*/
class Revision extends Node {
public function init(&$view, &$options) {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
if (!empty($this->options['link_to_node_revision'])) {
$this->additional_fields['vid'] = 'vid';
......