There are currently four patterns used by init() methods:

QueryPluginBase.php:           public function init($base_table, $base_field, $options) {
HandlerBase (and children):    public function init(&$view, &$options) {
PluginBase (and children):     public function init(&$view, &$display, $options = NULL) {
                               public function init(&$view, &$display, $options = array()) {
                               public function init(&$view, &$display) {
(LocalizationPluginBase)       public function init(&$view) {
(argument plugins)             public function init(&$view, &$argument, $options) {

The last 3 or 4 could all be easily unified, just pick a standard default argument for $options.
I'm not 100% sure about the argument plugin ones.

QueryPluginBase::init() should probably be renamed outright.

In addition, we need to clean up calls to $this->setOptionDefaults($this->options, $this->defineOptions());

Files: 
CommentFileSizeAuthor
#8 interdiff.txt816 bytesdawehner
#8 drupal-1778356-8.patch18.24 KBdawehner
PASSED: [[SimpleTest]]: [MySQL] 46,536 pass(es).
[ View ]
#6 interdiff.txt823 bytesdawehner
#6 drupal-1778356-6.patch18.19 KBdawehner
FAILED: [[SimpleTest]]: [MySQL] 46,314 pass(es), 0 fail(s), and 1,058 exception(s).
[ View ]
#4 drupal-1778356-4.patch17.74 KBdawehner
FAILED: [[SimpleTest]]: [MySQL] 46,390 pass(es), 2 fail(s), and 0 exception(s).
[ View ]
#2 core-1778356-2.patch17.01 KBdawehner
FAILED: [[SimpleTest]]: [MySQL] 45,396 pass(es), 157 fail(s), and 8,870 exception(s).
[ View ]

Comments

Good idea!

QueryPluginBase::init() should probably be renamed outright.

What about storing the view object on the query plugin? Then we could fetch the base_table and base_field directly form there.
This would be automatically be there if we have unified the init methods.

Regarding the argument plugins, we could introduce a setArgument/getArgument and just call this in get_plugin of the argument plugin base.

Project:Views» Drupal core
Version:8.x-3.x-dev» 8.x-dev
Component:Code» views.module
Status:Active» Needs review
StatusFileSize
new17.01 KB
FAILED: [[SimpleTest]]: [MySQL] 45,396 pass(es), 157 fail(s), and 8,870 exception(s).
[ View ]

Let's start with the query plugins.

Status:Needs review» Needs work

The last submitted patch, core-1778356-2.patch, failed testing.

Status:Needs work» Needs review
StatusFileSize
new17.74 KB
FAILED: [[SimpleTest]]: [MySQL] 46,390 pass(es), 2 fail(s), and 0 exception(s).
[ View ]

Rerolled for the getters method, and fixed some of bugs.

Status:Needs review» Needs work

The last submitted patch, drupal-1778356-4.patch, failed testing.

Status:Needs work» Needs review
StatusFileSize
new18.19 KB
FAILED: [[SimpleTest]]: [MySQL] 46,314 pass(es), 0 fail(s), and 1,058 exception(s).
[ View ]
new823 bytes

Ah getPlugin has to be adapted as well.

Status:Needs review» Needs work

The last submitted patch, drupal-1778356-6.patch, failed testing.

Status:Needs work» Needs review
StatusFileSize
new18.24 KB
PASSED: [[SimpleTest]]: [MySQL] 46,536 pass(es).
[ View ]
new816 bytes

Well, it would have been too nice.

Status:Needs review» Needs work

Not yet done. I still see a mixture of

public function init(ViewExecutable $view, &$display) {
public function init(ViewExecutable $view, &$display, $options = NULL) {
public function init(ViewExecutable $view, &$display, $options = array()) {

I would go with the 3th option everywhere

Title:Unify and standardize the init() methodUnify and standardize the init() method for the query plugin.
Status:Needs work» Needs review

This patch just tries to fix init methods of query plugins.

Status:Needs review» Reviewed & tested by the community

Than this is done but we need an issue for the other part of the problem written in the original report.

#8: drupal-1778356-8.patch queued for re-testing.

Status:Reviewed & tested by the community» Fixed

Thanks! Committed/pushed to 8.x.

Automatically closed -- issue fixed for 2 weeks with no activity.