Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
search.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
28 Jul 2013 at 16:19 UTC
Updated:
29 Jul 2014 at 22:42 UTC
Jump to comment: Most recent file
Comments
Comment #1
yanniboi commentedI've tested this patch against the 8.x branch of drupal and it seems to work well.
As to performance questions, I have included a validate function in the FormInterface implementation, but since at this time no validation is done, I was wondering if it would be better to just leave it out?
Comment #3
yanniboi commented#1: move_search_block_form_drupal_8_standard-2052325-1.patch queued for re-testing.
Comment #4
yesct commentedI think test coverage for this is provided in core/modules/search/lib/Drupal/search/Tests/SearchBlockTest.php
Comment #5
yesct commentedthese can be inheritdoc now #1906474: [policy adopted] Stop documenting methods with "Overrides …"
classes get third person verbs also. https://drupal.org/coding-standards/docs#classes
and some newlines: https://drupal.org/node/608152#indenting
and took out some trailing white space.
I'll test it next and take a look at the actual conversion.
Comment #6
yesct commentedI compared the
and the copy is very straight forward. so I think it is ok.
while looking I noticed $_GET
----
I think these $_GET should be replaced with getting from the request.
ending up with something like $this->request->query->get('...
Comment #7
yanniboi commentedOK, so I did some research on request (http://symfony.com/doc/2.0/components/http_foundation/introduction.html) and had a look at some examples on dependency injection. Then @dawehner pointed out that you can get the request in the formBuild() by doing:
So I added the protected $request in order to set it to the object in the build function and use it in the submit function.
I have tested this on a vanilla install, but I was unsure how to make sure the destination was set to test its removal.
Comment #9
yanniboi commentedDue to popular demand, here is an interdiff between 5 and 7.
Comment #10
yanniboi commented#7: move_search_block_form_drupal_8_standard-2052325-7.patch queued for re-testing.
Comment #11
dawehnerI was stumbling upon that isset. How can request not be set here. We figured it out that the request object is actually not injected from drupal_get_form. For form pages you have the controller resolver which cares about the injection but here we need to inject the request object into the SearchBlock plugin and then put it into the form arguments via drupal_get_form
This should not be an array, as drupal_get_form is already a render array.
Back in the days there has been two implementations ('search_block_form', 'search_theme_form'), so it is safe to remove now.
Comment #12
yanniboi commented@dawehner is a genius!! I am learning loads, thanks!
Ok, so I implemented ContainerFactoryPluginInterface to then use create() and __construct() in the SearchBlock class in order to get hold of $request, and then I passed it as an argument to drupal_get_form(). This seems to have worked and I have even tested using the search block in a drupal install with the destination set in the query. Everthing works as expected.
Comment #13
tstoecklerWow, this is an awesome patch. You removed search_box()!!! Nice...
Also, quite impressive that there's so little to complain after only ~10 comments on your first patch. Way to go!
I just found some small nitpicks, and then this should be ready to go.
I might be missing something, but I think these are not actually used in this file.
"Search" and "Block" should be lowercase.
Comment #14
yanniboi commented@tstoeckler, you are allowed to be nitpicky, this is core after all...
I followed your advice and made the changes as you described. Thanks for the feedback.
Comment #15
dawehnerThat is ready to fly now.
Comment #16
alexpottCommitted b397954 and pushed to 8.x. Thanks!
Comment #17.0
(not verified) commentedadding link to doc used to make the first patch.