Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ParisLiakos’s picture

Title: Convert aggregator_form_opml to a FormInterface implementation and routing definition. » Convert aggregator_form_opml to a FormInterface implementation and routing definition
Issue tags: -WSCCI
mtift’s picture

Assigned: Unassigned » mtift

I'll take this one.

mtift’s picture

Status: Active » Needs review
FileSize
12.89 KB

Here's my first attempt.

Status: Needs review » Needs work

The last submitted patch, aggregator-convert_aggregator_form_opml-1963410-3.patch, failed testing.

mtift’s picture

Status: Needs work » Needs review
FileSize
581 bytes
12.89 KB

Fixed "route_name" typo

Status: Needs review » Needs work

The last submitted patch, aggregator-convert_aggregator_form_opml-1963410-5.patch, failed testing.

ParisLiakos’s picture

Hi, thanks for picking this up!

Looks good so far, some notes:

+++ b/core/modules/aggregator/aggregator.routing.ymlundefined
@@ -4,3 +4,10 @@ aggregator_feed_items_delete:
+add_opml:

lets call the route aggregator_opml_add so it is consistent with the rest routes there and also correctly prefixed

+++ b/core/modules/aggregator/aggregator.routing.ymlundefined
@@ -4,3 +4,10 @@ aggregator_feed_items_delete:
+    _content: '\Drupal\aggregator\Form\FeedAddOpml'

it should be _form and lets call the class OpmlAdd or OpmlFeedAdd so its inline with FeedItemsDelete )verb last)

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedAddOpml.phpundefined
@@ -0,0 +1,172 @@
+      $response = drupal_http_request($form_state['values']['remote']);

this is being converted to guzzle on #1862524: Convert drupal_http_request usage in aggregator.module to Guzzle so when it is in (rtbc now) we can inject guzzle as well:)

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedAddOpml.phpundefined
@@ -0,0 +1,172 @@
+    $feeds = _aggregator_parse_opml($data);

opened #1963540: Move OPML parsing login in OpmlFeedAdd to a parser plugin for this, so we can inject this too, you can leave it as is for now:)

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedAddOpml.phpundefined
@@ -0,0 +1,172 @@
+      $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = :title OR url = :url", array(':title' => $feed['title'], ':url' => $feed['url']));

should get rid of db_query and use $this->database->query instead

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedAddOpml.phpundefined
@@ -0,0 +1,172 @@
+      $new_feed = entity_create('aggregator_feed', array(

Instead of using entity_create here, lets inject the entity manager and do what http://api.drupal.org/api/drupal/core!includes!entity.inc/function/entit... does:) get the storage and call create on it

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedAddOpml.phpundefined
@@ -0,0 +1,172 @@
+            'title' => $feed['title'],
+            'url' => $feed['url'],
+            'refresh' => $form_state['values']['refresh'],
+            'block' => $form_state['values']['block'],
+            ));

indentation is off

mtift’s picture

Status: Needs work » Needs review
FileSize
7.69 KB
12.94 KB

Thanks for the review, @rootatwc! The attached patch covers most of the comments in #7, except for the drupal_http_request() call.

Status: Needs review » Needs work

The last submitted patch, aggregator-convert_aggregator_form_opml-1963410-8.patch, failed testing.

ParisLiakos’s picture

the guzzle patch just committed so together with entity manager they should now be injected in the class

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.phpundefined
@@ -0,0 +1,174 @@
+      $new_feed = drupal_container()->get('plugin.manager.entity')

Not what i meant above.the plugin manager entity should be passed in the __construct with database, and should be stored in $this->entityManager..then no need to use drupal_container()

mtift’s picture

Status: Needs work » Needs review
FileSize
4.36 KB
14.54 KB

I got a bit confused with my re-roll, and ended up doing a straight diff rather than a git diff. I also felt a little odd blowing away the changes from #1862524: Convert drupal_http_request usage in aggregator.module to Guzzle and putting them right back into this patch.

ParisLiakos’s picture

great! entity plugin manager is injected now:)

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.phpundefined
@@ -0,0 +1,198 @@
+        $response = Drupal::httpClient()

This should be injected as well, together with database and entity manager:)
it should be stored in $this->httpClient

Status: Needs review » Needs work

The last submitted patch, aggregator-convert_aggregator_form_opml-1963410-11.patch, failed testing.

twistor’s picture

hmm...

#1963540: Move OPML parsing login in OpmlFeedAdd to a parser plugin would remove this entirely. Creating instead a different bundle with an OPML pipeline.

ParisLiakos’s picture

yeah but i am not really sure whether #1966070: Make aggregator feeds bundleable - move plugins configuration per bundle makes it in d8, so this is a really good step

mtift’s picture

Status: Needs work » Needs review
FileSize
2.48 KB
14.82 KB

So like this?

Status: Needs review » Needs work

The last submitted patch, aggregator-convert_aggregator_form_opml-1963410-16.patch, failed testing.

ParisLiakos’s picture

yes this looks great now, thanks
not sure why tests fail though, i should check manually once i find some time

ParisLiakos’s picture

Status: Needs work » Needs review
FileSize
17.94 KB

tests failed because _aggregator_parse_opml was in the admin.inc which was not loaded.
I moved it to a protected method to the controller with a todo above it.
Also injected the entityQuery and converted a query to use it instead:)

ParisLiakos’s picture

rerolled for conflict with multiple uploader patch, yay:)

ParisLiakos’s picture

uhm, wrong patch above, does not contain the addition in file_save_upload in the Controller

larowlan’s picture

This looks good to me, waiting for the bot

larowlan’s picture

Status: Needs review » Reviewed & tested by the community

I can't find anything wrong with #21 :)

ParisLiakos’s picture

alexpott’s picture

Assigned: mtift » Unassigned
Status: Reviewed & tested by the community » Fixed

Committed a1d4967 and pushed to 8.x. Thanks!

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