Issue #1776686 by aspilicious, tim.plunkett: Merge __construct() and construct().

8.0.x
aspilicious 2012-09-17 10:58:13 +02:00 committed by Tim Plunkett
parent 32cda04990
commit 3b3e139cf8
30 changed files with 171 additions and 86 deletions

View File

@ -47,8 +47,6 @@ abstract class PluginBase extends ComponentPluginBase {
parent::__construct($configuration, $plugin_id, $discovery);
$this->definition = $this->discovery->getDefinition($plugin_id) + $configuration;
$this->construct();
}
/**
@ -69,13 +67,6 @@ abstract class PluginBase extends ComponentPluginBase {
*/
protected function defineOptions() { return array(); }
/**
* Views handlers use a special construct function so that we can more
* easily construct them with variable arguments.
*/
public function construct() {
}
protected function setOptionDefaults(&$storage, $options, $level = 0) {
foreach ($options as $option => $definition) {
if (isset($definition['contains']) && is_array($definition['contains'])) {

View File

@ -9,6 +9,7 @@ namespace Drupal\views\Plugin\views\argument;
use Drupal\views\Plugin\views\PluginBase;
use Drupal\views\Plugin\views\HandlerBase;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* @defgroup views_argument_handlers Views argument handlers
@ -61,10 +62,10 @@ abstract class ArgumentPluginBase extends HandlerBase {
var $name_field;
/**
* Constructor
* Constructs a ArgumentPluginBase object.
*/
public function construct() {
parent::construct();
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
if (!empty($this->definition['name field'])) {
$this->name_field = $this->definition['name field'];

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\argument;
use Drupal\Core\Annotation\Plugin;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Abstract argument handler for simple formulae.
@ -28,10 +29,10 @@ class Formula extends ArgumentPluginBase {
var $formula = NULL;
/**
* Constructor
* Constructs a Formula object.
*/
public function construct() {
parent::construct();
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
if (!empty($this->definition['formula'])) {
$this->formula = $this->definition['formula'];

View File

@ -9,6 +9,7 @@ namespace Drupal\views\Plugin\views\field;
use Drupal\views\Plugin\views\HandlerBase;
use Drupal\Core\Annotation\Plugin;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* @defgroup views_field_handlers Views field handlers
@ -67,10 +68,10 @@ abstract class FieldPluginBase extends HandlerBase {
var $additional_fields = array();
/**
* Construct a new field handler.
* Constructs a FieldPluginBase object.
*/
public function construct() {
parent::construct();
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->additional_fields = array();
if (!empty($this->definition['additional fields'])) {

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\filter;
use Drupal\Core\Annotation\Plugin;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Simple filter to handle matching of boolean values
@ -38,7 +39,12 @@ class BooleanOperator extends FilterPluginBase {
// Whether to accept NULL as a false value or not
var $accept_null = FALSE;
public function construct() {
/**
* Constructs a BooleanOperator object.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->value_value = t('True');
if (isset($this->definition['label'])) {
$this->value_value = $this->definition['label'];
@ -50,7 +56,6 @@ class BooleanOperator extends FilterPluginBase {
$this->accept_null = (bool) $this->definition['accept_null'];
}
$this->value_options = NULL;
parent::construct();
}
/**

View File

@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\filter;
use Drupal\Core\Annotation\Plugin;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Simple filter to handle matching of multiple options selectable via checkboxes
@ -32,8 +33,12 @@ class InOperator extends FilterPluginBase {
*/
var $value_options = NULL;
public function construct() {
parent::construct();
/**
* Constructs a BooleanOperator object.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->value_title = t('Options');
$this->value_options = NULL;
}

View File

@ -11,6 +11,7 @@ use Drupal\views\View;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\PluginBase;
use Drupal\views\Plugin\views\wizard\WizardInterface;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Provides the interface and base class for Views Wizard plugins.
@ -108,12 +109,11 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
);
/**
* Constructs the WizardPluginBase object.
*
* @param array $definition
* The information stored in the annotation definition.
* Constructs a WizardPluginBase object.
*/
function construct() {
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->base_table = $this->definition['base_table'];
$entities = entity_get_info();

View File

@ -24,10 +24,11 @@ use Drupal\Core\Annotation\Plugin;
class Category extends FieldPluginBase {
/**
* Constructor to provide additional field to add.
* Constructs a Category object.
*/
public function construct() {
parent::construct();
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->additional_fields['cid'] = 'cid';
}

View File

@ -9,6 +9,7 @@ namespace Views\aggregator\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Field handler that turns an item's title into a clickable link to the original
@ -23,8 +24,12 @@ use Drupal\Core\Annotation\Plugin;
*/
class TitleLink extends FieldPluginBase {
public function construct() {
parent::construct();
/**
* Constructs a Category object.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->additional_fields['link'] = 'link';
}

View File

@ -9,6 +9,7 @@ namespace Views\comment\Plugin\views\field;
use Drupal\views\Plugin\views\field\Date;
use Drupal\Core\Annotation\Plugin;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Field handler to display the timestamp of a comment with the count of comments.
@ -22,8 +23,12 @@ use Drupal\Core\Annotation\Plugin;
*/
class LastTimestamp extends Date {
public function construct() {
parent::construct();
/**
* Constructs a LastTimestamp object.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->additional_fields['comment_count'] = 'comment_count';
}

View File

@ -9,6 +9,7 @@ namespace Views\comment\Plugin\views\field;
use Drupal\views\Plugin\views\field\Numeric;
use Drupal\Core\Annotation\Plugin;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Field handler to display the number of new comments.
@ -22,8 +23,12 @@ use Drupal\Core\Annotation\Plugin;
*/
class NodeNewComments extends Numeric {
public function construct() {
parent::construct();
/**
* Constructs a NodeNewComments object.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->additional_fields['nid'] = 'nid';
$this->additional_fields['type'] = 'type';
$this->additional_fields['comment_count'] = array('table' => 'node_comment_statistics', 'field' => 'comment_count');

View File

@ -9,6 +9,7 @@ namespace Views\filter\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Field handler to output the name of an input format.
@ -22,8 +23,12 @@ use Drupal\Core\Annotation\Plugin;
*/
class FormatName extends FieldPluginBase {
public function construct() {
parent::construct();
/**
* Constructs a FormatName object.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
// Be explicit about the table we are using.
$this->additional_fields['name'] = array('table' => 'filter_formats', 'field' => 'name');
}

View File

@ -9,6 +9,7 @@ namespace Views\locale\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Field handler to present a link to edit a translation.
@ -22,8 +23,12 @@ use Drupal\Core\Annotation\Plugin;
*/
class LinkEdit extends FieldPluginBase {
public function construct() {
parent::construct();
/**
* Constructs a LinkEdit object.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->additional_fields['lid'] = 'lid';
}

View File

@ -9,6 +9,7 @@ namespace Views\node\Plugin\views\argument;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\argument\Date;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Argument handler for a day (DD)
@ -21,10 +22,11 @@ use Drupal\views\Plugin\views\argument\Date;
class CreatedDay extends Date {
/**
* Constructor implementation
* Constructs a CreatedDay object.
*/
public function construct() {
parent::construct();
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->formula = views_date_sql_extract('DAY', "***table***.$this->realField");
$this->format = 'j';
$this->arg_format = 'd';

View File

@ -9,6 +9,7 @@ namespace Views\node\Plugin\views\argument;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\argument\Date;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Argument handler for a full date (CCYYMMDD)
@ -21,10 +22,11 @@ use Drupal\views\Plugin\views\argument\Date;
class CreatedFullDate extends Date {
/**
* Constructor implementation
* Constructs a CreatedFullDate object.
*/
public function construct() {
parent::construct();
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->format = 'F j, Y';
$this->arg_format = 'Ymd';
$this->formula = views_date_sql_format($this->arg_format, "***table***.$this->realField");

View File

@ -9,6 +9,7 @@ namespace Views\node\Plugin\views\argument;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\argument\Date;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Argument handler for a month (MM)
@ -21,10 +22,11 @@ use Drupal\views\Plugin\views\argument\Date;
class CreatedMonth extends Date {
/**
* Constructor implementation
* Constructs a CreatedMonth object.
*/
public function construct() {
parent::construct();
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->formula = views_date_sql_extract('MONTH', "***table***.$this->realField");
$this->format = 'F';
$this->arg_format = 'm';

View File

@ -9,6 +9,7 @@ namespace Views\node\Plugin\views\argument;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\argument\Date;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Argument handler for a week.
@ -21,10 +22,11 @@ use Drupal\views\Plugin\views\argument\Date;
class CreatedWeek extends Date {
/**
* Constructor implementation
* Constructs a CreatedWeek object.
*/
public function construct() {
parent::construct();
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->arg_format = 'w';
$this->formula = views_date_sql_extract('WEEK', "***table***.$this->realField");
}

View File

@ -9,6 +9,7 @@ namespace Views\node\Plugin\views\argument;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\argument\Date;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Argument handler for a year (CCYY)
@ -21,10 +22,11 @@ use Drupal\views\Plugin\views\argument\Date;
class CreatedYear extends Date {
/**
* Constructor implementation
* Constructs a CreatedYear object.
*/
public function construct() {
parent::construct();
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->arg_format = 'Y';
$this->formula = views_date_sql_extract('YEAR', "***table***.$this->realField");
}

View File

@ -9,6 +9,7 @@ namespace Views\node\Plugin\views\argument;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\argument\Date;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Argument handler for a year plus month (CCYYMM)
@ -21,10 +22,11 @@ use Drupal\views\Plugin\views\argument\Date;
class CreatedYearMonth extends Date {
/**
* Constructor implementation
* Constructs a CreatedYearMonth object.
*/
public function construct() {
parent::construct();
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->format = 'F Y';
$this->arg_format = 'Ym';
$this->formula = views_date_sql_format($this->arg_format, "***table***.$this->realField");

View File

@ -20,10 +20,6 @@ use Drupal\Core\Annotation\Plugin;
*/
class Type extends String {
public function construct() {
parent::construct('type');
}
/**
* Override the behavior of summary_name(). Get the user friendly version
* of the node type.

View File

@ -9,6 +9,7 @@ namespace Views\node\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Field handler to present the path to the node.
@ -22,6 +23,15 @@ use Drupal\Core\Annotation\Plugin;
*/
class Path extends FieldPluginBase {
/**
* Constructs a Path object.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->additional_fields['nid'] = 'nid';
}
protected function defineOptions() {
$options = parent::defineOptions();
$options['absolute'] = array('default' => FALSE, 'bool' => TRUE);
@ -29,11 +39,6 @@ class Path extends FieldPluginBase {
return $options;
}
public function construct() {
parent::construct();
$this->additional_fields['nid'] = 'nid';
}
public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
$form['absolute'] = array(

View File

@ -9,6 +9,7 @@ namespace Views\node\Plugin\views\field;
use Views\node\Plugin\views\field\Link;
use Drupal\Core\Annotation\Plugin;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Field handler to present a link to a node revision.
@ -22,8 +23,12 @@ use Drupal\Core\Annotation\Plugin;
*/
class RevisionLink extends Link {
public function construct() {
parent::construct();
/**
* Constructs a RevisionLink object.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->additional_fields['node_vid'] = array('table' => 'node_revision', 'field' => 'vid');
}

View File

@ -9,6 +9,7 @@ namespace Views\taxonomy\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Field handler to present a term edit link.
@ -22,8 +23,12 @@ use Drupal\Core\Annotation\Plugin;
*/
class LinkEdit extends FieldPluginBase {
public function construct() {
parent::construct();
/**
* Constructs a LinkEdit object.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->additional_fields['tid'] = 'tid';
$this->additional_fields['vid'] = 'vid';
$this->additional_fields['vocabulary_machine_name'] = array(

View File

@ -9,6 +9,7 @@ namespace Views\taxonomy\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;;
/**
* Field handler to provide simple renderer that allows linking to a taxonomy
@ -26,13 +27,14 @@ use Drupal\Core\Annotation\Plugin;
class Taxonomy extends FieldPluginBase {
/**
* Constructor to provide additional field to add.
* Constructs a Taxonomy object.
*
* This constructer assumes the taxonomy_term_data table. If using another
* table, we'll need to be more specific.
*/
public function construct() {
parent::construct();
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->additional_fields['vid'] = 'vid';
$this->additional_fields['tid'] = 'tid';
$this->additional_fields['vocabulary_machine_name'] = array(

View File

@ -9,6 +9,7 @@ namespace Views\translation\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Field handler to present a link to the node.
@ -22,8 +23,12 @@ use Drupal\Core\Annotation\Plugin;
*/
class NodeTranslationLink extends FieldPluginBase {
public function construct() {
parent::construct();
/**
* Constructs a NodeTranslationLink object.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->additional_fields['nid'] = 'nid';
$this->additional_fields['tnid'] = 'tnid';
$this->additional_fields['title'] = 'title';

View File

@ -9,6 +9,7 @@ namespace Views\user\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Field handler to present a link to the user.
@ -22,8 +23,12 @@ use Drupal\Core\Annotation\Plugin;
*/
class Link extends FieldPluginBase {
public function construct() {
parent::construct();
/**
* Constructs a Link object.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->additional_fields['uid'] = 'uid';
}

View File

@ -9,6 +9,7 @@ namespace Views\user\Plugin\views\field;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\field\PrerenderList;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Field handler to provide a list of permissions.
@ -22,8 +23,12 @@ use Drupal\views\Plugin\views\field\PrerenderList;
*/
class Permissions extends PrerenderList {
public function construct() {
parent::construct();
/**
* Constructs a Permissions object.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid');
}

View File

@ -9,6 +9,7 @@ namespace Views\user\Plugin\views\field;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Field handler to provide simple renderer that allows using a themed user link.
@ -22,8 +23,12 @@ use Drupal\views\Plugin\views\field\FieldPluginBase;
*/
class Picture extends FieldPluginBase {
public function construct() {
parent::construct();
/**
* Constructs a Picture object.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->additional_fields['uid'] = 'uid';
$this->additional_fields['name'] = 'name';
$this->additional_fields['mail'] = 'mail';

View File

@ -9,6 +9,7 @@ namespace Views\user\Plugin\views\field;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\field\PrerenderList;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Field handler to provide a list of roles.
@ -22,8 +23,12 @@ use Drupal\views\Plugin\views\field\PrerenderList;
*/
class Roles extends PrerenderList {
public function construct() {
parent::construct();
/**
* Constructs a Roles object.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid');
}

View File

@ -9,6 +9,7 @@ namespace Views\user\Plugin\views\filter;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\filter\BooleanOperator;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
/**
* Filter handler for the current user.
@ -22,8 +23,12 @@ use Drupal\views\Plugin\views\filter\BooleanOperator;
*/
class Current extends BooleanOperator {
public function construct() {
parent::construct();
/**
* Constructs a Current object.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
parent::__construct($configuration, $plugin_id, $discovery);
$this->value_value = t('Is the logged in user');
}