Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It is needed to create an interface for the public methods on ExposedFormPluginBase.
Solution
Create an interface and add all public methods in it. Implement this interface in ExposedFormPluginBase
Comment | File | Size | Author |
---|---|---|---|
#45 | interdiff-2642598-43-45.txt | 1.59 KB | dagmar |
#45 | exposed-forms-interface-2642598-45.patch | 17.11 KB | dagmar |
#43 | exposed-forms-interface-2642598-43.patch | 17.11 KB | dagmar |
#40 | interdiff-2642598-38-40.txt | 3.09 KB | dagmar |
#40 | exposed-forms-interface-2642598-40.patch | 17.45 KB | dagmar |
Comments
Comment #2
shabirahmad CreditAttribution: shabirahmad as a volunteer commentedComment #3
shabirahmad CreditAttribution: shabirahmad as a volunteer commentedComment #4
venkat.p1997 CreditAttribution: venkat.p1997 commentedThis is the first issue I am trying to fix. So, can you clarify what an interface is and maybe briefly explain what needs to be done?
Comment #5
jhodgdonThis does not seem like a real Novice project, actually.
Comment #6
tim.plunkettThere are different levels of novice, for sure. This would have been good for a PHP dev who is new to Drupal.
Still needs some work for the docblocks, those are marked with @todo.
Comment #7
jhodgdonThanks! This is a great start, and perhaps it is now a Novice project if you don't want to continue with it. :)
Things that need to be fixed/finished to finalize this:
Moving the @defgroup to the Interface file is a good idea. However, I think that we should then have
@ingroup views_exposed_form_plugins
added to the base class doc header, so that this base class still shows up on the Topic page.
We lost the information that was previously in this paragraph about the existence of the base class. Let's add that back in. There are other plugins with base classes you can look at for a model.. let's see... Here's the Block API topic, which mentions both the Block interface and the Block base plugin class.
https://api.drupal.org/api/drupal/core!modules!block!block.api.php/group...
Render -> Renders
This line I think needs some attention... doesn't make sense... seems garbled.
Comment #8
tim.plunkettI think this should be merged with #2640740: Fix docblocks in file ExposedFormPluginBase.php in order to address #7
Comment #9
shabirahmad CreditAttribution: shabirahmad as a volunteer commentedComment #10
mpdonadioShould this be a single interface, or should preRender / postRender / preExecute / postExecute be on their own, since other classes implement these (though with different arguments in a few cases)?
Comment #11
tim.plunkett@mpdonadio these specific methods with those params are unique to exposed forms, this is fine as is.
Comment #12
shabirahmad CreditAttribution: shabirahmad as a volunteer commentedChanges suggested https://www.drupal.org/node/2640740#comment-10709406 and https://www.drupal.org/node/2642598#comment-10716956
Comment #13
jhodgdonThanks! This is getting better.... It needs a bit of work here and there:
Adding an @see here to the new interface is good. But let's also keep the previous @see, because the base class is still very useful.
Thanks for adding the @ingroup here. However, it needs to go at the bottom of the doc block, not at the top.
See https://www.drupal.org/node/1354#order
Again: can we please add information here about the base class? I asked for this in my last review. See above comment, item 3 in comment #7.
This is a bit vague. Changes in what? I think all the pre/post functions maybe need a bit more explanation?
The first line here needs to end in a . also.
Any @param needs a documentation line below it.
See
https://www.drupal.org/node/1354#param
Needs @param docs.
I'm not sure we need "actual" in here?
before => after
Also not sure we need "actual" in here?
views -> the view
At least, all of the other functions refer to it that way.
Actually... Maybe we should make them all just say "the exposed form" and leave out the word "view" or "views"? I think that would be a bit more concise, and no less clear, since this is an interface for Views anyway.
First line docs for functions need to start with a verb. See
https://www.drupal.org/node/1354#functions
of exposed => of the exposed
needs comma before "and"
Comment #14
shabirahmad CreditAttribution: shabirahmad as a volunteer commentedComment #15
shabirahmad CreditAttribution: shabirahmad as a volunteer commentedRe-rolled the patch and made the necessary improvements.
Comment #16
dawehnerThis documentation is wrong. You just copied it from some other place, but postRender() is simply a method which is called after rendering was done. There are not field stuff involved here, see
core/modules/views/src/ViewExecutable.php:1435
Comment #17
jhodgdonYour interdiff file is also empty, which makes it difficult to see what you changed. Please make a new patch and an interdiff back to the patch in #12. Thanks!
Comment #18
shabirahmad CreditAttribution: shabirahmad as a volunteer commented1) updated patch.
2) correct interdiff file for 15
3) interdiff file for 17
Comment #19
jhodgdonPlease go back and read my review in #13. Most of this is repeated from that and previous reviews, which have STILL not been addressed.
In the future, please do NOT make patches without addressing previous reviews. It wastes reviewers time if you only address part of the reviews or completely ignore them. Thanks.
Sigh. I think I have made this comment multiple times now.
CAN WE PLEASE also have a mention in this paragraph of the base class and that being a useful starting point?
See my previous reviews for more thoughts on this.
These three lines should all line up -- there are extra spaces between @see and the first \ in two of them.
Also the second one has a stray word "annotation" at the end.
But really.. We don't need the @see lines here at all, since the previous paragraph links to all of these, and on api.drupal.org, presumably they will all be listed automagically by having @ingroup in each of the classes (except the one that is in this file, which is automatically included by being within the @{ @} brackets).
I don't think "the" is good here.
Also, this should probably have a bit more documentation. It doesn't even say it's for Views for instance, or tell what exposed filter forms are?
I don't think this paragraph makes sense. The use of FAPI doesn't imply that a form does anything with handlers.
rendered => is being rendered
(??)
Under what circumstances does it return an empty array? This needs to be documented.
What handlers are we talking about here? This is confusing.
Really I do not think this is a string? It is most likely a render array?
uh, these are vague.
This line is too long. As it is the first line of a function, it needs to be shortened to less than 80 characters and not wrapped.
Probably the thing to do is drop the part after the : and move that to a second sentence in the next paragraph instead.
Comment #20
claudiu.cristeaComment #21
deepak_123 CreditAttribution: deepak_123 as a volunteer commentedComment #22
claudiu.cristeaComment #23
dagmar@jhodgdon I think I addressed most of the comments you added on #19, please let me know if I forgot someone.
I was one of the developers who originally wrote the ExposedForms plugins so I made some modifications to some of the doc strings. I think the makes sense, but please let me know if they have some wording issues.
Comment #24
jhodgdonThanks! Reviewing the interdiff... still a lot that isn't right or wasn't addressed, sigh.
See item 1 in my previous review. Still not fixed.
So... In my previous review, I suggested removing all of these @see lines, since they're all mentioned in the previous paragraph. Or keeping them all but cleaning them up.
Instead, only one line was removed. I don't understand this. We should either remove all of them or leave all of them. And if we're leaving them (which is OK), remove the stray word 'annotation' at the end of the second one. Not remove the entire line.
I asked in my last review for more information to be added to this interface doc block. None was added. Please add more information.
This still doesn't make sense.
The first line says "Runs before the exposed form is rendered".
The next paragraph says it gives exposed forms more time to do something before fields are rendered... but ... huh? This says it is running before the exposed form is rendered, so how is that related to field rendering? I don't understand it.
First line of doc block needs to be a one-line summary, ending at 80 characters with a ., not a multi-line summary.
Also "perform some extra operation"... maybe "operations"? And... I don't really think this is much less vague than what was already there. Maybe say something like:
Implement if your exposed form needs to run code before query execution.
or something similar?
See previous item.
Again, this needs to be a one-line summary. Wrapping it to two lines is not OK.
Comment #25
dagmar@jhodgdon Thanks for your review.
Hm it seems I didn't spend enough time to fix all the items, sorry about that.. I will be working on this more deeply during this week to provide a complete patch on Thursday.
Comment #26
dagmar@jhodgdon I rewiewed with more details all your suggestions made on #13, #19 and 24. I'm providing several interdiff to make easier to review.
Hm, I checked, maybe you meant item #10?
Altough I checked that all the docblocks start with a single line explaning what the method does, I'm still not sure if preExecute, postExecute, preRender methods etc... have the right description, after all they are use to do "something" at different steps of the view render/execution. Maybe we could link to: ViewExecutable::build() which actually call most of those methods, what do you think?
Comment #27
jhodgdonThanks for the new patch! This time I started over and reviewed the entire patch, as the interdiffs were confusing. ;)
This sentence is ungrammatical.
Better:
These plugins can also alter the view query.
[I don't think we need the "based on the input..." part.]
Actually I don't understand what this paragraph is trying to say. How would you override it really? I mean, if you make a class that extends Basic, how would Views know to use your version? Maybe just leave this out?
If we're keeping this...
completely is misspelled
Also behavior should not have a u in it (we use American English spellings in the project).
A parameter doesn't really "determine" things. Also this is optional.
How about:
(optional) TRUE if the exposed form is being rendered as part of a block; FALSE (default) if not.
Looking at the code in the base class, I think we should also say that this method returns an empty array if the form is being rendered as a block.
Can we use an "Implement if..." paragraph here, like the other pre/post methods have now?
This is nice.
What type is this? We should always have a type in a @param line.
how about "rendered field output" instead of "field rendered output"?
That's rather odd. It looks like postRender() takes $output by reference, meaning presumably that it can be altered by the function. Does this really have a return value? Looking in ViewExecutable where this is called, I don't see it using a return value, so I suspect it doesn't have one.
How about changing this to the "Implement if..." wording too?
This @see seems like it might be useful for exposedFormAlter() and exposedFormValidate() also.
Anyway... all three of these methods are kind of confusing. There's this method renderExposedForm()... I guess I don't understand, from the documentation here, how these three methods are related to the form returned by that method, if they are at all, or is it a different form? or what? Very confusing. It especially doesn't make sense that a plugin that is returning a form would also need to alter it itself? Needs explanation.
We don't really need a : at the end of this line.
Comment #28
dagmarThanks!
I replaced this with the docs of the original code on ViewsExcutable.
Agree, deleted.
I see what you mean. So basically there are two steps when building the exposed forms. The first step request all the widgets to all the filters and sorts handlers configured to be exposed, and the second one is like a final alter method that can see all the attached widgets. I included some extra docs to clarify that. I hope now be more clear.
Comment #29
jhodgdonGreat! This is getting much better.
A few minor things remaining:
This plugins => These plugins
Again, this needs more explanation if it's going to stay in this patch. I don't think that if you just make a new exposed form class it will be used by a view.
And... really what is this trying to say? Let's just leave it out. I don't think it provides any useful information that is not in the first paragraph? If it does, I am not understanding it.
This @see line should be justified left (it has two spaces before the @see now), and also you need a blank line between the @param docs and the @see.
Also when linking to a method, add () after the method name:
... ::render()
This sentence is mixing up present and past tense.
And... Oh, I finally get why this method exists. Thanks!
So can I suggest something more like this maybe:
The exposed form is built by calling the renderExposedForm() method on this class, and then letting each exposed filter and sort handler add widgets to the form. After that is finished, this method is called to let the class alter the finished form.
Or something like that?
Then it would be useful if this alter method and the render method have @see lines linking to each other, I think?
Comment #30
dagmarThanks @jhodgdon. Addressed Items 1 to 4 on this patch.
I just discovered two more things. First, resetForm should not be part of the interface since it is called from the ExposedFormPluginBase class, so force other plugins to implement this method should not be neccessary (the exposed form could event not have a reset button as a UI option). I documented the resetForm method on the base class and removed the method from the interface.
And second, the postExecute method is never actually called (This is the reasone becuase there is no @see on that docblock). I'll open another issue to address that, for now I just defined the method on the interface.
Comment #32
dagmarUnrelated test failures.
Comment #33
jhodgdonThis is getting better, but is still not quite ready:
Again, can we please have an @see that links this method to the alter form method on the interface?
Let's take out the word "being" here.
was -> is
Question: Is this really a string, and not a render array? Because if it is, it would be really really really difficult to alter, and it seems pointless to pass it as an argument to this function.
Does it make sense to have the same @see line added here as there is in the preExcecute() method?
Again, can we also have an @see that points to the renderExposedForm on this interface?
grammar nitpick:
which -> that
Also please rewrap these two lines into a paragraph. The first line is pretty short. And the second sentence isn't really a sentence, so how about fixing that too? Could say:
... exposed_raw_input; for example, 'form_build_id'.
Comment #34
dagmarThanks! Items 1, 2, 3, 6, 7 and 8 fixed on this patch.
Regarding 4:
Yes it is an string. The pager plugin is also receiving this as an string, I think is better to open another issue if we want to change this on both plugins.
Regarding 5:
I opened #2679493: postExecute() is never called on exposed form plugins since this method is not called anywhere.
Comment #35
jhodgdonI have no energy for reviewing this patch any more, sorry. Let's move it into the Views component and let the views maintainers deal with it.
Comment #36
dagmar@jhodgdon Thanks for your help! @dawehner please let me know if you need anyting else here.
Comment #38
dagmarRerolled for 8.2.x.
Comment #39
jhodgdonI took a quick look over this patch. There are a few small grammar/punctuation things that could be improved:
Consider making this into two sentences, ending the first one after "is triggered", for clarity? Or at least adding some punctuation there.
"extend Xyz class" either needs to be "extend the Xyz class" or just "extend Xyz" (without the word "class"). As it is, it is not grammatical.
I am not actually sure I agree that the base class "provides common utility methods". What it does is provide a base implementation of many/all of the methods in the interface (I'm not sure if it's many or all).
But really, people reading this documentation probably understand what "base class" means, so you could probably just leave out the whole "which" clause here.
"use the annotations defined by Xyz" => "are annotated with Xyz annotation".
I think that this interface's doc block should have @see links to both the base class and the annoation.
For should be lower-case
Comment #40
dagmarThanks @jhodgdon. I think this should achieve all your comments.
Comment #42
jhodgdonPatch doesn't apply, apparently.
Comment #43
dagmarSorry, accidentaly a temporal file was included in the patch.
Comment #44
jhodgdonLooking very good! I found just two small things to address, introduced by the latest changes:
Did this say "Also" before? Ah, no, that was one sentence before joined by and... So. It isn't an "also", is it? I think this (now separate second) sentence is just explaining what it does.
So I suggest changing "Also" to "In the base class, it"
This should end in .
Comment #45
dagmarThanks
Comment #46
jhodgdonOK, I think this is fine now. Thanks!
Comment #47
alexpottFixed on commit - @file is no longer required in PSR0/4 classes.
Comment #48
alexpottCommitted 567b140 and pushed to 8.2.x. Thanks!