Issue #1850792 by damiankloip, dawehner, tim.plunkett: Make init() method consistent across all views plugins.

8.0.x
webchick 2012-12-21 21:11:43 -08:00
parent 532ea17f07
commit dc6c7a4be9
63 changed files with 350 additions and 251 deletions

View File

@ -8,6 +8,7 @@
namespace Drupal\comment\Plugin\views\field; namespace Drupal\comment\Plugin\views\field;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -24,10 +25,13 @@ use Drupal\Core\Annotation\Plugin;
class Comment extends FieldPluginBase { class Comment extends FieldPluginBase {
/** /**
* Override init function to provide generic option to link to comment. * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::init().
*
* Provide generic option to link to comment.
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
if (!empty($this->options['link_to_comment'])) { if (!empty($this->options['link_to_comment'])) {
$this->additional_fields['cid'] = 'cid'; $this->additional_fields['cid'] = 'cid';
$this->additional_fields['nid'] = 'nid'; $this->additional_fields['nid'] = 'nid';

View File

@ -8,6 +8,7 @@
namespace Drupal\comment\Plugin\views\field; namespace Drupal\comment\Plugin\views\field;
use Drupal\views\Plugin\views\field\Date; use Drupal\views\Plugin\views\field\Date;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -26,8 +27,8 @@ class LastTimestamp extends Date {
/** /**
* Overrides Drupal\views\Plugin\views\field\FieldPluginBase::init(). * Overrides Drupal\views\Plugin\views\field\FieldPluginBase::init().
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
$this->additional_fields['comment_count'] = 'comment_count'; $this->additional_fields['comment_count'] = 'comment_count';
} }

View File

@ -8,6 +8,7 @@
namespace Drupal\comment\Plugin\views\field; namespace Drupal\comment\Plugin\views\field;
use Drupal\views\Plugin\views\field\Numeric; use Drupal\views\Plugin\views\field\Numeric;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -26,8 +27,8 @@ class NodeNewComments extends Numeric {
/** /**
* Overrides Drupal\views\Plugin\views\field\FieldPluginBase::init(). * Overrides Drupal\views\Plugin\views\field\FieldPluginBase::init().
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
$this->additional_fields['nid'] = 'nid'; $this->additional_fields['nid'] = 'nid';
$this->additional_fields['type'] = 'type'; $this->additional_fields['type'] = 'type';

View File

@ -8,6 +8,7 @@
namespace Drupal\comment\Plugin\views\field; namespace Drupal\comment\Plugin\views\field;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -24,10 +25,13 @@ use Drupal\Core\Annotation\Plugin;
class Username extends FieldPluginBase { class Username extends FieldPluginBase {
/** /**
* Override init function to add uid and homepage fields. * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::init().
*
* Add uid and homepage fields.
*/ */
public function init(ViewExecutable $view, &$data) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $data); parent::init($view, $display, $options);
$this->additional_fields['uid'] = 'uid'; $this->additional_fields['uid'] = 'uid';
$this->additional_fields['homepage'] = 'homepage'; $this->additional_fields['homepage'] = 'homepage';
} }

View File

@ -8,6 +8,7 @@
namespace Drupal\field\Plugin\views\argument; namespace Drupal\field\Plugin\views\argument;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\argument\Numeric; use Drupal\views\Plugin\views\argument\Numeric;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -31,8 +32,12 @@ class FieldList extends Numeric {
*/ */
var $allowed_values = NULL; var $allowed_values = NULL;
public function init(ViewExecutable $view, &$options) { /**
parent::init($view, $options); * Overrides \Drupal\views\Plugin\views\argument\ArgumentPluginBase::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
$field = field_info_field($this->definition['field_name']); $field = field_info_field($this->definition['field_name']);
$this->allowed_values = options_allowed_values($field); $this->allowed_values = options_allowed_values($field);
} }

View File

@ -8,6 +8,7 @@
namespace Drupal\field\Plugin\views\argument; namespace Drupal\field\Plugin\views\argument;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\argument\String; use Drupal\views\Plugin\views\argument\String;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -31,8 +32,12 @@ class ListString extends String {
*/ */
var $allowed_values = NULL; var $allowed_values = NULL;
public function init(ViewExecutable $view, &$options) { /**
parent::init($view, $options); * Overrides \Drupal\views\Plugin\views\argument\String::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
$field = field_info_field($this->definition['field_name']); $field = field_info_field($this->definition['field_name']);
$this->allowed_values = options_allowed_values($field); $this->allowed_values = options_allowed_values($field);
} }

View File

@ -8,6 +8,7 @@
namespace Drupal\field\Plugin\views\field; namespace Drupal\field\Plugin\views\field;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -66,8 +67,11 @@ class Field extends FieldPluginBase {
*/ */
public $instance; public $instance;
public function init(ViewExecutable $view, &$options) { /**
parent::init($view, $options); * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
$this->field_info = $field = field_info_field($this->definition['field_name']); $this->field_info = $field = field_info_field($this->definition['field_name']);
$this->multiple = FALSE; $this->multiple = FALSE;

View File

@ -8,6 +8,7 @@
namespace Drupal\field\Plugin\views\relationship; namespace Drupal\field\Plugin\views\relationship;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\relationship\RelationshipPluginBase; use Drupal\views\Plugin\views\relationship\RelationshipPluginBase;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -23,8 +24,11 @@ use Drupal\Core\Annotation\Plugin;
*/ */
class EntityReverse extends RelationshipPluginBase { class EntityReverse extends RelationshipPluginBase {
public function init(ViewExecutable $view, &$options) { /**
parent::init($view, $options); * Overrides \Drupal\views\Plugin\views\relationship\RelationshipPluginBase::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
$this->field_info = field_info_field($this->definition['field_name']); $this->field_info = field_info_field($this->definition['field_name']);
} }

View File

@ -8,6 +8,7 @@
namespace Drupal\file\Plugin\views\field; namespace Drupal\file\Plugin\views\field;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase;
@ -24,10 +25,11 @@ use Drupal\views\Plugin\views\field\FieldPluginBase;
class File extends FieldPluginBase { class File extends FieldPluginBase {
/** /**
* Constructor to provide additional field to add. * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::init().
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
if (!empty($options['link_to_file'])) { if (!empty($options['link_to_file'])) {
$this->additional_fields['uri'] = 'uri'; $this->additional_fields['uri'] = 'uri';
} }

View File

@ -8,6 +8,7 @@
namespace Drupal\node\Plugin\views\field; namespace Drupal\node\Plugin\views\field;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\node\Plugin\views\field\Node; use Drupal\node\Plugin\views\field\Node;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -26,8 +27,12 @@ use Drupal\Core\Annotation\Plugin;
*/ */
class HistoryUserTimestamp extends Node { class HistoryUserTimestamp extends Node {
public function init(ViewExecutable $view, &$options) { /**
parent::init($view, $options); * Overrides \Drupal\node\Plugin\views\field\Node::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
global $user; global $user;
if ($user->uid) { if ($user->uid) {
$this->additional_fields['created'] = array('table' => 'node', 'field' => 'created'); $this->additional_fields['created'] = array('table' => 'node', 'field' => 'created');

View File

@ -8,6 +8,7 @@
namespace Drupal\node\Plugin\views\field; namespace Drupal\node\Plugin\views\field;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -25,8 +26,12 @@ use Drupal\Core\Annotation\Plugin;
*/ */
class Node extends FieldPluginBase { class Node extends FieldPluginBase {
public function init(ViewExecutable $view, &$options) { /**
parent::init($view, $options); * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
// Don't add the additional fields to groupby // Don't add the additional fields to groupby
if (!empty($this->options['link_to_node'])) { if (!empty($this->options['link_to_node'])) {
$this->additional_fields['nid'] = array('table' => 'node', 'field' => 'nid'); $this->additional_fields['nid'] = array('table' => 'node', 'field' => 'nid');

View File

@ -8,6 +8,7 @@
namespace Drupal\node\Plugin\views\field; namespace Drupal\node\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -24,10 +25,10 @@ use Drupal\Core\Annotation\Plugin;
class Path extends FieldPluginBase { class Path extends FieldPluginBase {
/** /**
* Overrides Drupal\views\Plugin\views\field\FieldPluginBase::init(). * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::init().
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
$this->additional_fields['nid'] = 'nid'; $this->additional_fields['nid'] = 'nid';
} }

View File

@ -8,6 +8,7 @@
namespace Drupal\node\Plugin\views\field; namespace Drupal\node\Plugin\views\field;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\node\Plugin\views\field\Node; use Drupal\node\Plugin\views\field\Node;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -23,8 +24,12 @@ use Drupal\Core\Annotation\Plugin;
*/ */
class Revision extends Node { class Revision extends Node {
public function init(ViewExecutable $view, &$options) { /**
parent::init($view, $options); * Overrides \Drupal\node\Plugin\views\field\Node::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
if (!empty($this->options['link_to_node_revision'])) { if (!empty($this->options['link_to_node_revision'])) {
$this->additional_fields['vid'] = 'vid'; $this->additional_fields['vid'] = 'vid';
$this->additional_fields['nid'] = 'nid'; $this->additional_fields['nid'] = 'nid';

View File

@ -8,6 +8,7 @@
namespace Drupal\node\Plugin\views\field; namespace Drupal\node\Plugin\views\field;
use Drupal\node\Plugin\views\field\Link; use Drupal\node\Plugin\views\field\Link;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -26,8 +27,8 @@ class RevisionLink extends Link {
/** /**
* Overrides Drupal\views\Plugin\views\field\FieldPluginBase::init(). * Overrides Drupal\views\Plugin\views\field\FieldPluginBase::init().
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
$this->additional_fields['node_vid'] = array('table' => 'node_revision', 'field' => 'vid'); $this->additional_fields['node_vid'] = array('table' => 'node_revision', 'field' => 'vid');
} }

View File

@ -8,6 +8,7 @@
namespace Drupal\system\Plugin\views\row; namespace Drupal\system\Plugin\views\row;
use Drupal\views\Plugin\views\row\RowPluginBase; use Drupal\views\Plugin\views\row\RowPluginBase;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
/** /**
@ -51,12 +52,12 @@ class EntityRow extends RowPluginBase {
protected $build = array(); protected $build = array();
/** /**
* Overrides Drupal\views\Plugin\views\row\RowPluginBase::init(). * Overrides Drupal\views\Plugin\views\PluginBase::init().
*/ */
public function init(ViewExecutable $view, &$display, $options = NULL) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options); parent::init($view, $display, $options);
$this->entityType = $this->definition['entity_type'];
$this->entityType = $this->definition['entity_type'];
$this->entityInfo = entity_get_info($this->entityType); $this->entityInfo = entity_get_info($this->entityType);
$this->base_table = $this->entityInfo['base_table']; $this->base_table = $this->entityInfo['base_table'];
$this->base_field = $this->entityInfo['entity_keys']['id']; $this->base_field = $this->entityInfo['entity_keys']['id'];

View File

@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Plugin\views\argument_default; namespace Drupal\taxonomy\Plugin\views\argument_default;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation; use Drupal\Core\Annotation\Translation;
use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase; use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
@ -23,8 +24,22 @@ use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
*/ */
class Tid extends ArgumentDefaultPluginBase { class Tid extends ArgumentDefaultPluginBase {
public function init(ViewExecutable $view, &$argument, $options) { /**
parent::init($view, $argument, $options); * Overrides \Drupal\views\Plugin\views\Plugin\views\PluginBase::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
// @todo Remove the legacy code.
// Convert legacy vids option to machine name vocabularies.
if (!empty($this->options['vids'])) {
$vocabularies = taxonomy_vocabulary_get_names();
foreach ($this->options['vids'] as $vid) {
if (isset($vocabularies[$vid], $vocabularies[$vid]->machine_name)) {
$this->options['vocabularies'][$vocabularies[$vid]->machine_name] = $vocabularies[$vid]->machine_name;
}
}
}
} }
protected function defineOptions() { protected function defineOptions() {

View File

@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Plugin\views\argument_validator; namespace Drupal\taxonomy\Plugin\views\argument_validator;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation; use Drupal\Core\Annotation\Translation;
use Drupal\views\Plugin\views\argument_validator\ArgumentValidatorPluginBase; use Drupal\views\Plugin\views\argument_validator\ArgumentValidatorPluginBase;
@ -23,8 +24,22 @@ use Drupal\views\Plugin\views\argument_validator\ArgumentValidatorPluginBase;
*/ */
class Term extends ArgumentValidatorPluginBase { class Term extends ArgumentValidatorPluginBase {
public function init(ViewExecutable $view, &$argument, $options) { /**
parent::init($view, $argument, $options); * Overrides \Drupal\views\Plugin\views\Plugin\views\PluginBase::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
// @todo Remove the legacy code.
// Convert legacy vids option to machine name vocabularies.
if (!empty($this->options['vids'])) {
$vocabularies = taxonomy_vocabulary_get_names();
foreach ($this->options['vids'] as $vid) {
if (isset($vocabularies[$vid], $vocabularies[$vid]->machine_name)) {
$this->options['vocabularies'][$vocabularies[$vid]->machine_name] = $vocabularies[$vid]->machine_name;
}
}
}
} }
protected function defineOptions() { protected function defineOptions() {

View File

@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Plugin\views\field; namespace Drupal\taxonomy\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -26,8 +27,8 @@ class LinkEdit extends FieldPluginBase {
/** /**
* Overrides Drupal\views\Plugin\views\field\FieldPluginBase::init(). * Overrides Drupal\views\Plugin\views\field\FieldPluginBase::init().
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
$this->additional_fields['tid'] = 'tid'; $this->additional_fields['tid'] = 'tid';
$this->additional_fields['vid'] = 'vid'; $this->additional_fields['vid'] = 'vid';

View File

@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Plugin\views\field; namespace Drupal\taxonomy\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -32,8 +33,8 @@ class Taxonomy extends FieldPluginBase {
* This method assumes the taxonomy_term_data table. If using another table, * This method assumes the taxonomy_term_data table. If using another table,
* we'll need to be more specific. * we'll need to be more specific.
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
$this->additional_fields['vid'] = 'vid'; $this->additional_fields['vid'] = 'vid';
$this->additional_fields['tid'] = 'tid'; $this->additional_fields['tid'] = 'tid';

View File

@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Plugin\views\field; namespace Drupal\taxonomy\Plugin\views\field;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\PrerenderList; use Drupal\views\Plugin\views\field\PrerenderList;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -23,8 +24,12 @@ use Drupal\Core\Annotation\Plugin;
*/ */
class TaxonomyIndexTid extends PrerenderList { class TaxonomyIndexTid extends PrerenderList {
public function init(ViewExecutable $view, &$options) { /**
parent::init($view, $options); * Overrides \Drupal\views\Plugin\views\field\PrerenderList::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
// @todo: Wouldn't it be possible to use $this->base_table and no if here? // @todo: Wouldn't it be possible to use $this->base_table and no if here?
if ($view->storage->get('base_table') == 'node_revision') { if ($view->storage->get('base_table') == 'node_revision') {
$this->additional_fields['nid'] = array('table' => 'node_revision', 'field' => 'nid'); $this->additional_fields['nid'] = array('table' => 'node_revision', 'field' => 'nid');

View File

@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Plugin\views\filter; namespace Drupal\taxonomy\Plugin\views\filter;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\filter\ManyToOne; use Drupal\views\Plugin\views\filter\ManyToOne;
@ -26,8 +27,12 @@ class TaxonomyIndexTid extends ManyToOne {
// Stores the exposed input for this filter. // Stores the exposed input for this filter.
var $validated_exposed_input = NULL; var $validated_exposed_input = NULL;
public function init(ViewExecutable $view, &$options) { /**
parent::init($view, $options); * Overrides \Drupal\views\Plugin\views\filter\ManyToOne::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
if (!empty($this->definition['vocabulary'])) { if (!empty($this->definition['vocabulary'])) {
$this->options['vid'] = $this->definition['vocabulary']; $this->options['vid'] = $this->definition['vocabulary'];
} }

View File

@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Plugin\views\relationship; namespace Drupal\taxonomy\Plugin\views\relationship;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\relationship\RelationshipPluginBase; use Drupal\views\Plugin\views\relationship\RelationshipPluginBase;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -23,8 +24,22 @@ use Drupal\Core\Annotation\Plugin;
*/ */
class NodeTermData extends RelationshipPluginBase { class NodeTermData extends RelationshipPluginBase {
public function init(ViewExecutable $view, &$options) { /**
parent::init($view, $options); * Overrides \Drupal\views\Plugin\views\relationship\RelationshipPluginBase::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
// @todo Remove the legacy code.
// Convert legacy vids option to machine name vocabularies.
if (!empty($this->options['vids'])) {
$vocabularies = taxonomy_vocabulary_get_names();
foreach ($this->options['vids'] as $vid) {
if (isset($vocabularies[$vid], $vocabularies[$vid]->machine_name)) {
$this->options['vocabularies'][$vocabularies[$vid]->machine_name] = $vocabularies[$vid]->machine_name;
}
}
}
} }
protected function defineOptions() { protected function defineOptions() {

View File

@ -8,6 +8,7 @@
namespace Drupal\user\Plugin\views\field; namespace Drupal\user\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -27,8 +28,8 @@ class Link extends FieldPluginBase {
/** /**
* Overrides Drupal\views\Plugin\views\field\FieldPluginBase::init(). * Overrides Drupal\views\Plugin\views\field\FieldPluginBase::init().
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
$this->additional_fields['uid'] = 'uid'; $this->additional_fields['uid'] = 'uid';
} }

View File

@ -8,6 +8,7 @@
namespace Drupal\user\Plugin\views\field; namespace Drupal\user\Plugin\views\field;
use Drupal\user\Plugin\views\field\User; use Drupal\user\Plugin\views\field\User;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
@ -24,10 +25,13 @@ use Drupal\views\ViewExecutable;
class Name extends User { class Name extends User {
/** /**
* Overrides \Drupal\user\Plugin\views\field\User::init().
*
* Add uid in the query so we can test for anonymous if needed. * Add uid in the query so we can test for anonymous if needed.
*/ */
public function init(ViewExecutable $view, &$data) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $data); parent::init($view, $display, $options);
if (!empty($this->options['overwrite_anonymous']) || !empty($this->options['format_username'])) { if (!empty($this->options['overwrite_anonymous']) || !empty($this->options['format_username'])) {
$this->additional_fields['uid'] = 'uid'; $this->additional_fields['uid'] = 'uid';
} }

View File

@ -8,6 +8,7 @@
namespace Drupal\user\Plugin\views\field; namespace Drupal\user\Plugin\views\field;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\field\PrerenderList; use Drupal\views\Plugin\views\field\PrerenderList;
@ -26,8 +27,8 @@ class Permissions extends PrerenderList {
/** /**
* Overrides Drupal\views\Plugin\views\field\FieldPluginBase::init(). * Overrides Drupal\views\Plugin\views\field\FieldPluginBase::init().
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
$this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid'); $this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid');
} }

View File

@ -8,6 +8,7 @@
namespace Drupal\user\Plugin\views\field; namespace Drupal\user\Plugin\views\field;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\field\PrerenderList; use Drupal\views\Plugin\views\field\PrerenderList;
@ -26,8 +27,8 @@ class Roles extends PrerenderList {
/** /**
* Overrides Drupal\views\Plugin\views\field\FieldPluginBase::init(). * Overrides Drupal\views\Plugin\views\field\FieldPluginBase::init().
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
$this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid'); $this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid');
} }

View File

@ -8,6 +8,7 @@
namespace Drupal\user\Plugin\views\field; namespace Drupal\user\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
@ -24,10 +25,11 @@ use Drupal\views\ViewExecutable;
class User extends FieldPluginBase { class User extends FieldPluginBase {
/** /**
* Override init function to provide generic option to link to user. * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::init().
*/ */
public function init(ViewExecutable $view, &$data) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $data); parent::init($view, $display, $options);
if (!empty($this->options['link_to_user'])) { if (!empty($this->options['link_to_user'])) {
$this->additional_fields['uid'] = 'uid'; $this->additional_fields['uid'] = 'uid';
} }

View File

@ -8,6 +8,7 @@
namespace Drupal\user\Plugin\views\filter; namespace Drupal\user\Plugin\views\filter;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\filter\BooleanOperator; use Drupal\views\Plugin\views\filter\BooleanOperator;
@ -26,8 +27,8 @@ class Current extends BooleanOperator {
/** /**
* Overrides Drupal\views\Plugin\views\filter\BooleanOperator::init(). * Overrides Drupal\views\Plugin\views\filter\BooleanOperator::init().
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
$this->value_value = t('Is the logged in user'); $this->value_value = t('Is the logged in user');
} }

View File

@ -80,7 +80,7 @@ class DisplayArray implements \ArrayAccess, \Iterator, \Countable {
$this->displayHandlers[$display_id] = drupal_container()->get("plugin.manager.views.display")->createInstance('default'); $this->displayHandlers[$display_id] = drupal_container()->get("plugin.manager.views.display")->createInstance('default');
} }
$this->displayHandlers[$display_id]->init($this->view, $display); $this->displayHandlers[$display_id]->initDisplay($this->view, $display);
// If this is not the default display handler, let it know which is since // If this is not the default display handler, let it know which is since
// it may well utilize some data from the default. // it may well utilize some data from the default.
if ($display_id != 'default') { if ($display_id != 'default') {

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views; namespace Drupal\views\Plugin\views;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface; use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\PluginBase; use Drupal\views\Plugin\views\PluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\Core\Database\Database; use Drupal\Core\Database\Database;
@ -80,17 +81,11 @@ abstract class HandlerBase extends PluginBase {
} }
/** /**
* Init the handler with necessary data. * Overrides \Drupal\views\Plugin\views\PluginBase::init().
*
* @param Drupal\views\ViewExecutable $view
* The $view object this handler is attached to.
* @param array $options
* The item from the database; the actual contents of this will vary
* based upon the type of handler.
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
$this->setOptionDefaults($this->options, $this->defineOptions()); parent::init($view, $display, $options);
$this->view = &$view;
$display_id = $this->view->current_display; $display_id = $this->view->current_display;
// Check to see if this handler type is defaulted. Note that // Check to see if this handler type is defaulted. Note that
// we have to do a lookup because the type is singular but the // we have to do a lookup because the type is singular but the

View File

@ -8,7 +8,9 @@
namespace Drupal\views\Plugin\views; namespace Drupal\views\Plugin\views;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface; use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\Component\Plugin\PluginBase as ComponentPluginBase; use Drupal\Component\Plugin\PluginBase as ComponentPluginBase;
use Drupal\views\ViewExecutable;
abstract class PluginBase extends ComponentPluginBase { abstract class PluginBase extends ComponentPluginBase {
@ -61,6 +63,24 @@ abstract class PluginBase extends ComponentPluginBase {
$this->definition = $this->discovery->getDefinition($plugin_id) + $configuration; $this->definition = $this->discovery->getDefinition($plugin_id) + $configuration;
} }
/**
* Initialize the plugin.
*
* @param \Drupal\views\ViewExecutable $view
* The view object.
* @param \Drupal\views\Plugin\views\display\DisplayPluginBase $display
* The display handler.
* @param array $options
* The options configured for this plugin.
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = $view;
$this->displayHandler = $display;
$this->unpackOptions($this->options, $options);
}
/** /**
* Information about options for all kinds of purposes will be held here. * Information about options for all kinds of purposes will be held here.
* @code * @code

View File

@ -24,22 +24,6 @@ use Drupal\views\ViewExecutable;
*/ */
abstract class AccessPluginBase extends PluginBase { abstract class AccessPluginBase extends PluginBase {
/**
* Initialize the plugin.
*
* @param $view
* The view object.
* @param $display
* The display handler.
*/
public function init(ViewExecutable $view, &$display, $options = NULL) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->displayHandler = &$display;
$this->unpackOptions($this->options, $options);
}
/** /**
* Retrieve the options when this is a new access * Retrieve the options when this is a new access
* control plugin * control plugin

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\area; namespace Drupal\views\Plugin\views\area;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\PluginBase; use Drupal\views\Plugin\views\PluginBase;
use Drupal\views\Plugin\views\HandlerBase; use Drupal\views\Plugin\views\HandlerBase;
@ -31,9 +32,8 @@ abstract class AreaPluginBase extends HandlerBase {
* Make sure that no result area handlers are set to be shown when the result * Make sure that no result area handlers are set to be shown when the result
* is empty. * is empty.
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
$this->setOptionDefaults($this->options, $this->defineOptions()); parent::init($view, $display, $options);
parent::init($view, $options);
if (isset($this->handler_type) && ($this->handler_type == 'empty')) { if (isset($this->handler_type) && ($this->handler_type == 'empty')) {
$this->options['empty'] = TRUE; $this->options['empty'] = TRUE;

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\argument; namespace Drupal\views\Plugin\views\argument;
use Drupal\views\Plugin\views\PluginBase; use Drupal\views\Plugin\views\PluginBase;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\HandlerBase; use Drupal\views\Plugin\views\HandlerBase;
@ -64,8 +65,8 @@ abstract class ArgumentPluginBase extends HandlerBase {
/** /**
* Overrides Drupal\views\Plugin\views\HandlerBase:init(). * Overrides Drupal\views\Plugin\views\HandlerBase:init().
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
if (!empty($this->definition['name field'])) { if (!empty($this->definition['name field'])) {
$this->name_field = $this->definition['name field']; $this->name_field = $this->definition['name field'];
@ -339,6 +340,7 @@ abstract class ArgumentPluginBase extends HandlerBase {
), ),
), ),
'#id' => 'edit-options-validate-options-' . $id, '#id' => 'edit-options-validate-options-' . $id,
'#default_value' => array(),
); );
$plugin->buildOptionsForm($form['validate']['options'][$id], $form_state); $plugin->buildOptionsForm($form['validate']['options'][$id], $form_state);
$validate_types[$id] = $info['title']; $validate_types[$id] = $info['title'];
@ -544,6 +546,7 @@ abstract class ArgumentPluginBase extends HandlerBase {
':input[name="options[default_argument_type]"]' => array('value' => $id), ':input[name="options[default_argument_type]"]' => array('value' => $id),
), ),
), ),
'#default_value' => array(),
); );
$options[$id] = $info['title']; $options[$id] = $info['title'];
$plugin->buildOptionsForm($form['argument_default'][$id], $form_state); $plugin->buildOptionsForm($form['argument_default'][$id], $form_state);
@ -631,6 +634,7 @@ abstract class ArgumentPluginBase extends HandlerBase {
':input[name="options[summary][format]"]' => array('value' => $id), ':input[name="options[summary][format]"]' => array('value' => $id),
), ),
), ),
'#default_value' => array(),
); );
$options[$id] = $info['title']; $options[$id] = $info['title'];
$plugin->buildOptionsForm($form['summary']['options'][$id], $form_state); $plugin->buildOptionsForm($form['summary']['options'][$id], $form_state);
@ -1055,12 +1059,11 @@ abstract class ArgumentPluginBase extends HandlerBase {
$plugin = drupal_container()->get("plugin.manager.views.$type")->createInstance($name); $plugin = drupal_container()->get("plugin.manager.views.$type")->createInstance($name);
if ($plugin) { if ($plugin) {
// Style plugins expects different parameters as argument related plugins. $plugin->init($this->view, $this->displayHandler, $options);
if ($type == 'style') {
$plugin->init($this->view, $this->view->display_handler->display, $options); if ($type !== 'style') {
} // It's an argument_default/argument_validate plugin, so set the argument.
else { $plugin->setArgument($this);
$plugin->init($this->view, $this, $options);
} }
return $plugin; return $plugin;
} }

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\argument; namespace Drupal\views\Plugin\views\argument;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
/** /**
@ -31,8 +32,8 @@ class Formula extends ArgumentPluginBase {
/** /**
* Overrides Drupal\views\Plugin\views\argument\ArgumentPluginBase::init(). * Overrides Drupal\views\Plugin\views\argument\ArgumentPluginBase::init().
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
if (!empty($this->definition['formula'])) { if (!empty($this->definition['formula'])) {
$this->formula = $this->definition['formula']; $this->formula = $this->definition['formula'];

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\argument; namespace Drupal\views\Plugin\views\argument;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\views\ManyToOneHelper; use Drupal\views\ManyToOneHelper;
@ -30,8 +31,12 @@ use Drupal\views\ManyToOneHelper;
*/ */
class ManyToOne extends ArgumentPluginBase { class ManyToOne extends ArgumentPluginBase {
public function init(ViewExecutable $view, &$options) { /**
parent::init($view, $options); * Overrides \Drupal\views\Plugin\views\argument\ArgumentPluginBase::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
$this->helper = new ManyToOneHelper($this); $this->helper = new ManyToOneHelper($this);
// Ensure defaults for these, during summaries and stuff: // Ensure defaults for these, during summaries and stuff:

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\argument; namespace Drupal\views\Plugin\views\argument;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ManyToOneHelper; use Drupal\views\ManyToOneHelper;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -23,8 +24,12 @@ use Drupal\Core\Annotation\Plugin;
*/ */
class String extends ArgumentPluginBase { class String extends ArgumentPluginBase {
public function init(ViewExecutable $view, &$options) { /**
parent::init($view, $options); * Overrides \Drupal\views\Plugin\views\argument\ArgumentPluginBase::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
if (!empty($this->definition['many to one'])) { if (!empty($this->definition['many to one'])) {
$this->helper = new ManyToOneHelper($this); $this->helper = new ManyToOneHelper($this);

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\argument_default; namespace Drupal\views\Plugin\views\argument_default;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\argument\ArgumentPluginBase;
use Drupal\views\Plugin\views\PluginBase; use Drupal\views\Plugin\views\PluginBase;
/** /**
@ -21,6 +22,13 @@ use Drupal\views\Plugin\views\PluginBase;
*/ */
abstract class ArgumentDefaultPluginBase extends PluginBase { abstract class ArgumentDefaultPluginBase extends PluginBase {
/**
* The argument handler instance associated with this plugin.
*
* @var \Drupal\views\Plugin\views\argument\ArgumentPluginBase
*/
protected $argument;
/** /**
* Return the default argument. * Return the default argument.
* *
@ -29,15 +37,13 @@ abstract class ArgumentDefaultPluginBase extends PluginBase {
function get_argument() { } function get_argument() { }
/** /**
* Initialize this plugin with the view and the argument * Sets the parent argument this plugin is associated with.
* it is linked to. *
* @param \Drupal\views\Plugin\views\argument\ArgumentPluginBase $argument
* The parent argument to set.
*/ */
public function init(ViewExecutable $view, &$argument, $options) { public function setArgument(ArgumentPluginBase $argument) {
$this->setOptionDefaults($this->options, $this->defineOptions()); $this->argument = $argument;
$this->view = &$view;
$this->argument = &$argument;
$this->unpackOptions($this->options, $options);
} }
/** /**

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\argument_validator; namespace Drupal\views\Plugin\views\argument_validator;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\argument\ArgumentPluginBase;
use Drupal\views\Plugin\views\PluginBase; use Drupal\views\Plugin\views\PluginBase;
/** /**
@ -22,15 +23,20 @@ use Drupal\views\Plugin\views\PluginBase;
abstract class ArgumentValidatorPluginBase extends PluginBase { abstract class ArgumentValidatorPluginBase extends PluginBase {
/** /**
* Initialize this plugin with the view and the argument * The argument handler instance associated with this plugin.
* it is linked to. *
* @var \Drupal\views\Plugin\views\argument\ArgumentPluginBase
*/ */
public function init(ViewExecutable $view, &$argument, $options) { protected $argument;
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->argument = &$argument;
$this->unpackOptions($this->options, $options); /**
* Sets the parent argument this plugin is associated with.
*
* @param \Drupal\views\Plugin\views\argument\ArgumentPluginBase $argument
* The parent argument to set.
*/
public function setArgument(ArgumentPluginBase $argument) {
$this->argument = $argument;
} }
/** /**

View File

@ -57,22 +57,6 @@ abstract class CachePluginBase extends PluginBase {
*/ */
protected $outputKey; protected $outputKey;
/**
* Initialize the plugin.
*
* @param $view
* The view object.
* @param $display
* The display handler.
*/
public function init(ViewExecutable $view, &$display, $options = NULL) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->displayHandler = &$display;
$this->unpackOptions($this->options, $options);
}
/** /**
* Returns the outputKey property. * Returns the outputKey property.
* *

View File

@ -96,9 +96,9 @@ abstract class DisplayPluginBase extends PluginBase {
*/ */
protected $usesAreas = TRUE; protected $usesAreas = TRUE;
public function init(ViewExecutable $view, &$display, $options = NULL) { public function initDisplay(ViewExecutable $view, array &$display, array &$options = NULL) {
$this->setOptionDefaults($this->options, $this->defineOptions()); $this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view; $this->view = $view;
$this->display = &$display; $this->display = &$display;
// Load extenders as soon as possible. // Load extenders as soon as possible.
@ -882,7 +882,7 @@ abstract class DisplayPluginBase extends PluginBase {
$handler->handler_type = $type; $handler->handler_type = $type;
} }
$handler->init($this->view, $info); $handler->init($this->view, $this, $info);
$this->handlers[$type][$id] = &$handler; $this->handlers[$type][$id] = &$handler;
} }
@ -2308,7 +2308,7 @@ abstract class DisplayPluginBase extends PluginBase {
if ($plugin) { if ($plugin) {
// Because pagers have very similar options, let's allow pagers to // Because pagers have very similar options, let's allow pagers to
// try to carry the options over. // try to carry the options over.
$plugin->init($this->view, $this->display, $pager['options']); $plugin->init($this->view, $this, $pager['options']);
$pager = array('type' => $form_state['values']['pager']['type'], 'options' => $plugin->options); $pager = array('type' => $form_state['values']['pager']['type'], 'options' => $plugin->options);
$this->setOption('pager', $pager); $this->setOption('pager', $pager);

View File

@ -42,8 +42,11 @@ class Feed extends PathPluginBase {
*/ */
protected $usesPager = FALSE; protected $usesPager = FALSE;
public function init(ViewExecutable $view, &$display, $options = NULL) { /**
parent::init($view, $display, $options); * Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::initDisplay().
*/
public function initDisplay(ViewExecutable $view, array &$display, array &$options = NULL) {
parent::initDisplay($view, $display, $options);
// Set the default row style. Ideally this would be part of the option // Set the default row style. Ideally this would be part of the option
// definition, but in this case it's dependent on the view's base table, // definition, but in this case it's dependent on the view's base table,

View File

@ -18,12 +18,6 @@ use Drupal\Core\Annotation\Translation;
*/ */
abstract class DisplayExtenderPluginBase extends PluginBase { abstract class DisplayExtenderPluginBase extends PluginBase {
public function init(ViewExecutable $view, &$display) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = $view;
$this->displayHandler = $display;
}
/** /**
* Provide a form to edit options for this plugin. * Provide a form to edit options for this plugin.
*/ */

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\exposed_form; namespace Drupal\views\Plugin\views\exposed_form;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\PluginBase; use Drupal\views\Plugin\views\PluginBase;
/** /**
@ -28,22 +29,6 @@ abstract class ExposedFormPluginBase extends PluginBase {
*/ */
protected $usesOptions = TRUE; protected $usesOptions = TRUE;
/**
* Initialize the plugin.
*
* @param $view
* The view object.
* @param $display
* The display handler.
*/
public function init(ViewExecutable $view, &$display, $options = array()) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->displayHandler = &$display;
$this->unpackOptions($this->options, $options);
}
protected function defineOptions() { protected function defineOptions() {
$options = parent::defineOptions(); $options = parent::defineOptions();
$options['submit_button'] = array('default' => 'Apply', 'translatable' => TRUE); $options['submit_button'] = array('default' => 'Apply', 'translatable' => TRUE);

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\field; namespace Drupal\views\Plugin\views\field;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
/** /**
@ -40,8 +41,11 @@ class Boolean extends FieldPluginBase {
return $options; return $options;
} }
public function init(ViewExecutable $view, &$options) { /**
parent::init($view, $options); * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
$default_formats = array( $default_formats = array(
'yes-no' => array(t('Yes'), t('No')), 'yes-no' => array(t('Yes'), t('No')),

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\field; namespace Drupal\views\Plugin\views\field;
use Drupal\views\Plugin\views\HandlerBase; use Drupal\views\Plugin\views\HandlerBase;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -70,8 +71,8 @@ abstract class FieldPluginBase extends HandlerBase {
/** /**
* Overrides Drupal\views\Plugin\views\HandlerBase::init(). * Overrides Drupal\views\Plugin\views\HandlerBase::init().
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
$this->additional_fields = array(); $this->additional_fields = array();
if (!empty($this->definition['additional fields'])) { if (!empty($this->definition['additional fields'])) {

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\field; namespace Drupal\views\Plugin\views\field;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
/** /**
@ -27,8 +28,11 @@ use Drupal\views\ViewExecutable;
*/ */
class Markup extends FieldPluginBase { class Markup extends FieldPluginBase {
public function init(ViewExecutable $view, &$options) { /**
parent::init($view, $options); * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
$this->format = $this->definition['format']; $this->format = $this->definition['format'];

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\filter; namespace Drupal\views\Plugin\views\filter;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
/** /**
@ -40,10 +41,10 @@ class BooleanOperator extends FilterPluginBase {
var $accept_null = FALSE; var $accept_null = FALSE;
/** /**
* Overrides Drupal\views\Plugin\views\filter\FilterPluginBase::init(). * Overrides \Drupal\views\Plugin\views\filter\FilterPluginBase::init().
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
$this->value_value = t('True'); $this->value_value = t('True');
if (isset($this->definition['label'])) { if (isset($this->definition['label'])) {

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\filter; namespace Drupal\views\Plugin\views\filter;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
/** /**
@ -21,11 +22,16 @@ use Drupal\views\ViewExecutable;
*/ */
class Broken extends FilterPluginBase { class Broken extends FilterPluginBase {
/**
* Overrides \Drupal\views\Plugin\views\filter\FilterPluginBase::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
}
public function adminLabel($short = FALSE) { public function adminLabel($short = FALSE) {
return t('Broken/missing handler'); return t('Broken/missing handler');
} }
public function init(ViewExecutable $view, &$options) { }
public function defineOptions() { return array(); } public function defineOptions() { return array(); }
public function ensureMyTable() { /* No table to ensure! */ } public function ensureMyTable() { /* No table to ensure! */ }
public function query($group_by = FALSE) { /* No query to run */ } public function query($group_by = FALSE) { /* No query to run */ }

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\filter; namespace Drupal\views\Plugin\views\filter;
use Drupal\views\Plugin\views\HandlerBase; use Drupal\views\Plugin\views\HandlerBase;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
@ -74,13 +75,15 @@ abstract class FilterPluginBase extends HandlerBase {
var $always_required = FALSE; var $always_required = FALSE;
/** /**
* Overrides \Drupal\views\Plugin\views\HandlerBase::init().
*
* Provide some extra help to get the operator/value easier to use. * Provide some extra help to get the operator/value easier to use.
* *
* This likely has to be overridden by filters which are more complex * This likely has to be overridden by filters which are more complex
* than simple operator/value. * than simple operator/value.
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
$this->operator = $this->options['operator']; $this->operator = $this->options['operator'];
$this->value = $this->options['value']; $this->value = $this->options['value'];

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\filter; namespace Drupal\views\Plugin\views\filter;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
/** /**
@ -34,10 +35,10 @@ class InOperator extends FilterPluginBase {
var $value_options = NULL; var $value_options = NULL;
/** /**
* Overrides Drupal\views\Plugin\views\filter\FilterPluginBase::init(). * Overrides \Drupal\views\Plugin\views\filter\FilterPluginBase::init().
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $options); parent::init($view, $display, $options);
$this->value_title = t('Options'); $this->value_title = t('Options');
$this->value_options = NULL; $this->value_options = NULL;

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\filter; namespace Drupal\views\Plugin\views\filter;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ManyToOneHelper; use Drupal\views\ManyToOneHelper;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -34,8 +35,12 @@ class ManyToOne extends InOperator {
*/ */
var $helper = NULL; var $helper = NULL;
public function init(ViewExecutable $view, &$options) { /**
parent::init($view, $options); * Overrides \Drupal\views\Plugin\views\filter\InOperator::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
$this->helper = new ManyToOneHelper($this); $this->helper = new ManyToOneHelper($this);
} }

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\pager; namespace Drupal\views\Plugin\views\pager;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation; use Drupal\Core\Annotation\Translation;
@ -25,7 +26,10 @@ use Drupal\Core\Annotation\Translation;
*/ */
class None extends PagerPluginBase { class None extends PagerPluginBase {
public function init(ViewExecutable $view, &$display, $options = array()) { /**
* Overrides \Drupal\views\Plugin\views\PluginBase::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options); parent::init($view, $display, $options);
// If the pager is set to none, then it should show all items. // If the pager is set to none, then it should show all items.

View File

@ -33,22 +33,6 @@ abstract class PagerPluginBase extends PluginBase {
*/ */
protected $usesOptions = TRUE; protected $usesOptions = TRUE;
/**
* Initialize the plugin.
*
* @param $view
* The view object.
* @param $display
* The display handler.
*/
public function init(ViewExecutable $view, &$display, $options = array()) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->displayHandler = &$display;
$this->unpackOptions($this->options, $options);
}
/** /**
* Get how many items per page this pager will display. * Get how many items per page this pager will display.
* *

View File

@ -23,17 +23,6 @@ abstract class QueryPluginBase extends PluginBase implements QueryInterface {
*/ */
var $pager = NULL; var $pager = NULL;
/**
* Overrides Drupal\views\Plugin\views\PluginBase::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array $options = array()) {
$this->view = $view;
$this->displayHandler = $display;
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->unpackOptions($this->options, $options);
}
/** /**
* Generate a query and a countquery from all of the information supplied * Generate a query and a countquery from all of the information supplied
* to the object. * to the object.

View File

@ -115,10 +115,11 @@ class Sql extends QueryPluginBase {
var $no_distinct; var $no_distinct;
/** /**
* Overrides Drupal\views\Plugin\views\query\QueryPluginBase::init(). * Overrides \Drupal\views\Plugin\views\PluginBase::init().
*/ */
public function init(ViewExecutable $view, DisplayPluginBase $display, array $options = array()) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options); parent::init($view, $display, $options);
$base_table = $this->view->storage->get('base_table'); $base_table = $this->view->storage->get('base_table');
$base_field = $this->view->storage->get('base_field'); $base_field = $this->view->storage->get('base_field');
$this->relationships[$base_table] = array( $this->relationships[$base_table] = array(

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\relationship; namespace Drupal\views\Plugin\views\relationship;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\HandlerBase; use Drupal\views\Plugin\views\HandlerBase;
use Drupal\views\Join; use Drupal\views\Join;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
@ -45,12 +46,14 @@ use Drupal\Core\Annotation\Plugin;
abstract class RelationshipPluginBase extends HandlerBase { abstract class RelationshipPluginBase extends HandlerBase {
/** /**
* Overrides \Drupal\views\Plugin\views\HandlerBase::init().
*
* Init handler to let relationships live on tables other than * Init handler to let relationships live on tables other than
* the table they operate on. * the table they operate on.
*/ */
public function init(ViewExecutable $view, &$options) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
$this->setOptionDefaults($this->options, $this->defineOptions()); parent::init($view, $display, $options);
parent::init($view, $options);
if (isset($this->definition['relationship table'])) { if (isset($this->definition['relationship table'])) {
$this->table = $this->definition['relationship table']; $this->table = $this->definition['relationship table'];
} }

View File

@ -37,18 +37,6 @@ abstract class RowPluginBase extends PluginBase {
*/ */
protected $usesFields = FALSE; protected $usesFields = FALSE;
/**
* Initialize the row plugin.
*/
public function init(ViewExecutable $view, &$display, $options = NULL) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->displayHandler = &$display;
// Overlay incoming options on top of defaults
$this->unpackOptions($this->options, $options);
}
/** /**
* Returns the usesFields property. * Returns the usesFields property.
* *

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\sort; namespace Drupal\views\Plugin\views\sort;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
/** /**
@ -19,12 +20,15 @@ use Drupal\views\ViewExecutable;
*/ */
class GroupByNumeric extends SortPluginBase { class GroupByNumeric extends SortPluginBase {
public function init(ViewExecutable $view, &$options) { /**
parent::init($view, $options); * Overrides \Drupal\views\Plugin\views\HandlerBase::init().
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
// Initialize the original handler. // Initialize the original handler.
$this->handler = views_get_handler($options['table'], $options['field'], 'sort'); $this->handler = views_get_handler($options['table'], $options['field'], 'sort');
$this->handler->init($view, $options); $this->handler->init($view, $display, $options);
} }
/** /**

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\style; namespace Drupal\views\Plugin\views\style;
use Drupal\views\Plugin\views\PluginBase; use Drupal\views\Plugin\views\PluginBase;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\wizard\WizardInterface; use Drupal\views\Plugin\views\wizard\WizardInterface;
use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation; use Drupal\Core\Annotation\Translation;
@ -80,20 +81,13 @@ abstract class StylePluginBase extends PluginBase {
protected $usesFields = FALSE; protected $usesFields = FALSE;
/** /**
* Initialize a style plugin. * Overrides \Drupal\views\Plugin\views\PluginBase::init().
* *
* @param $view * The style options might come externally as the style can be sourced from at
* @param $display * least two locations. If it's not included, look on the display.
* @param $options
* 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(ViewExecutable $view, &$display, $options = NULL) { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
$this->setOptionDefaults($this->options, $this->defineOptions()); parent::init($view, $display, $options);
$this->view = &$view;
$this->displayHandler = &$display;
$this->unpackOptions($this->options, $options);
if ($this->usesRowPlugin() && $display->getOption('row')) { if ($this->usesRowPlugin() && $display->getOption('row')) {
$this->row_plugin = $display->getPlugin('row'); $this->row_plugin = $display->getPlugin('row');

View File

@ -79,7 +79,7 @@ class StyleTest extends ViewTestBase {
$view->initStyle(); $view->initStyle();
$view->style_plugin->setUsesRowPlugin(TRUE); $view->style_plugin->setUsesRowPlugin(TRUE);
// Reinitialize the style as it supports row plugins now. // Reinitialize the style as it supports row plugins now.
$view->style_plugin->init($view, $view->display_handler, array()); $view->style_plugin->init($view, $view->display_handler);
$this->assertTrue($view->style_plugin->row_plugin instanceof RowTest, 'Make sure the right row plugin class is loaded.'); $this->assertTrue($view->style_plugin->row_plugin instanceof RowTest, 'Make sure the right row plugin class is loaded.');
$random_text = $this->randomName(); $random_text = $this->randomName();

View File

@ -2214,7 +2214,7 @@ class ViewExecutable {
if (!empty($this->displayHandlers[$id])) { if (!empty($this->displayHandlers[$id])) {
// Initialize the new display handler with data. // Initialize the new display handler with data.
$this->displayHandlers[$id]->init($this, $display[$id]); $this->displayHandlers[$id]->initDisplay($this, $display[$id]);
// If this is NOT the default display handler, let it know which is // If this is NOT the default display handler, let it know which is
if ($id != 'default') { if ($id != 'default') {
// @todo is the '&' still required in php5? // @todo is the '&' still required in php5?

View File

@ -1445,7 +1445,7 @@ function views_ui_config_item_form($form, &$form_state) {
$base = $data[$relationship['field']]['relationship']['base']; $base = $data[$relationship['field']]['relationship']['base'];
$base_fields = views_fetch_fields($base, $form_state['type'], $executable->display_handler->useGroupBy()); $base_fields = views_fetch_fields($base, $form_state['type'], $executable->display_handler->useGroupBy());
if (isset($base_fields[$item['table'] . '.' . $item['field']])) { if (isset($base_fields[$item['table'] . '.' . $item['field']])) {
$relationship_handler->init($executable, $relationship); $relationship_handler->init($executable, $executable->display_handler, $relationship);
$relationship_options[$relationship['id']] = $relationship_handler->label(); $relationship_options[$relationship['id']] = $relationship_handler->label();
} }
} }
@ -1557,7 +1557,7 @@ function views_ui_config_item_form_submit_temporary($form, &$form_state) {
// Create a new handler and unpack the options from the form onto it. We // Create a new handler and unpack the options from the form onto it. We
// can use that for storage. // can use that for storage.
$handler = views_get_handler($item['table'], $item['field'], $handler_type, $override); $handler = views_get_handler($item['table'], $item['field'], $handler_type, $override);
$handler->init($executable, $item); $handler->init($executable, $executable->display_handler, $item);
// Add the incoming options to existing options because items using // Add the incoming options to existing options because items using
// the extra form may not have everything in the form here. // the extra form may not have everything in the form here.
@ -1612,7 +1612,7 @@ function views_ui_config_item_form_submit($form, &$form_state) {
// Create a new handler and unpack the options from the form onto it. We // Create a new handler and unpack the options from the form onto it. We
// can use that for storage. // can use that for storage.
$handler = views_get_handler($item['table'], $item['field'], $handler_type, $override); $handler = views_get_handler($item['table'], $item['field'], $handler_type, $override);
$handler->init($executable, $item); $handler->init($executable, $executable->display_handler, $item);
// Add the incoming options to existing options because items using // Add the incoming options to existing options because items using
// the extra form may not have everything in the form here. // the extra form may not have everything in the form here.
@ -1665,7 +1665,7 @@ function views_ui_config_item_group_form($type, &$form_state) {
$form['markup'] = array('#markup' => t("Error: handler for @table > @field doesn't exist!", array('@table' => $item['table'], '@field' => $item['field']))); $form['markup'] = array('#markup' => t("Error: handler for @table > @field doesn't exist!", array('@table' => $item['table'], '@field' => $item['field'])));
} }
else { else {
$handler->init($view, $item); $handler->init($executable, $executable->display_handler, $item);
$types = ViewExecutable::viewsHandlerTypes(); $types = ViewExecutable::viewsHandlerTypes();
$form['#title'] = t('Configure group settings for @type %item', array('@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel())); $form['#title'] = t('Configure group settings for @type %item', array('@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()));
@ -1688,12 +1688,13 @@ function views_ui_config_item_group_form_submit($form, &$form_state) {
$id = $form_state['id']; $id = $form_state['id'];
$handler = views_get_handler($item['table'], $item['field'], $type); $handler = views_get_handler($item['table'], $item['field'], $type);
$handler->init($form_state['view']->get('executable'), $item); $executable = $form_state['view']->get('executable');
$handler->init($executable, $executable->display_handler, $item);
$handler->submitGroupByForm($form, $form_state); $handler->submitGroupByForm($form, $form_state);
// Store the item back on the view // Store the item back on the view
$form_state['view']->get('executable')->setItem($form_state['display_id'], $form_state['type'], $form_state['id'], $item); $executable->setItem($form_state['display_id'], $form_state['type'], $form_state['id'], $item);
// Write to cache // Write to cache
views_ui_cache_set($form_state['view']); views_ui_cache_set($form_state['view']);
@ -1767,7 +1768,7 @@ function views_ui_config_item_extra_form($form, &$form_state) {
$form['markup'] = array('#markup' => t("Error: handler for @table > @field doesn't exist!", array('@table' => $item['table'], '@field' => $item['field']))); $form['markup'] = array('#markup' => t("Error: handler for @table > @field doesn't exist!", array('@table' => $item['table'], '@field' => $item['field'])));
} }
else { else {
$handler->init($view, $item); $handler->init($executable, $executable->display_handler, $item);
$types = ViewExecutable::viewsHandlerTypes(); $types = ViewExecutable::viewsHandlerTypes();
$form['#title'] = t('Configure extra settings for @type %item', array('@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel())); $form['#title'] = t('Configure extra settings for @type %item', array('@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()));