Comments

ParisLiakos’s picture

Component: base system » aggregator.module

oops

ParisLiakos’s picture

lets postpone it on #1972262: Convert aggregator_feed_add to a new style controller to get AggregatorController in

ParisLiakos’s picture

Status: Active » Postponed
ParisLiakos’s picture

Status: Postponed » Active

up for grabs:)

marcingy’s picture

Assigned: Unassigned » marcingy
marcingy’s picture

Status: Active » Needs review
StatusFileSize
new5.1 KB

This is going to fail, the main issue is that auto loading of aggregator_feed is not being triggered. Help welcome

Status: Needs review » Needs work

The last submitted patch, feed-controller.patch, failed testing.

ParisLiakos’s picture

Looks good:)

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.phpundefined
@@ -56,4 +68,23 @@ public function feedAdd() {
+  public function feedRefresh(Feed $feed) {

it is not loaded cause you named it $feed here. you should name the variable the way you registered it in route..here $aggregator_feed should work

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.phpundefined
@@ -56,4 +68,23 @@ public function feedAdd() {
+    drupal_goto('admin/config/services/aggregator');

as a bonus you could try to convert it to RedirectResponse().not sure if it is supposed to work though

marcingy’s picture

Status: Needs work » Needs review
StatusFileSize
new5.26 KB

Ok think I have got to bottom of the issues. Parameters passed into a controller need to match those defined in the route.

marcingy’s picture

Yes I just worked out the parameter stuff :)

as a bonus you could try to convert it to RedirectResponse().not sure if it is supposed to work though

This is being covered in another issue and yes it might work but lets not scope creep. #1668866: Replace drupal_goto() with RedirectResponse

ParisLiakos’s picture

Sure

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.phpundefined
@@ -8,8 +8,11 @@
+use Drupal\aggregator\Plugin\Core\Entity\Feed;

@@ -56,4 +69,23 @@ public function feedAdd() {
+  public function feedRefresh(Feed $aggregator_feed) {

We are supposed now to typehint with the Interface, so it should be FeedInterface now, not Feed. Make sure you pulled before trying it:)
#1391694: Use type-hinting for entity-parameters

Otherwise i cant see what else can be done here

marcingy’s picture

StatusFileSize
new5.32 KB

Updated to use interface type hinting

dawehner’s picture

Yeah more wscci conversions!

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.phpundefined
@@ -8,8 +8,13 @@
 use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\HttpFoundation\Request;
 use Drupal\Core\ControllerInterface;
+use Drupal\aggregator\Plugin\Core\Entity\Feed;
 use Drupal\Core\Entity\EntityManager;
+use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
+use Symfony\Component\HttpFoundation\RedirectResponse;

It would be cool to have them ordered properly.

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.phpundefined
@@ -24,20 +29,30 @@ class AggregatorController implements ControllerInterface {
+   * Stores the Entity manager.

I thought we store the Request :)

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.phpundefined
@@ -56,4 +71,23 @@ public function feedAdd() {
+   * @param \Drupal\aggregator\Plugin\Core\Entity\Feed $aggregator_feed

Please let's also use the interface in the documentation of the method.

marcingy’s picture

StatusFileSize
new5.25 KB

Re-ordered Use statements and updated docs :)

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Great!

ParisLiakos’s picture

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.phpundefined
@@ -8,8 +8,12 @@
+use Drupal\aggregator\Plugin\Core\Entity\Feed;

i think this is no longer needed since we are using the Interface, right?

dawehner’s picture

Status: Reviewed & tested by the community » Needs work

Good catch!

ParisLiakos’s picture

something new i learned:

+++ b/core/modules/aggregator/aggregator.routing.ymlundefined
@@ -32,3 +32,10 @@ aggregator_opml_add:
+    _controller: '\Drupal\aggregator\Routing\AggregatorController::feedRefresh'

should be _content
if we keep it to _controller then drupal_goto should be RedirectResponse

ParisLiakos’s picture

Status: Needs work » Needs review
StatusFileSize
new3.46 KB
new5.56 KB

Status: Needs review » Needs work

The last submitted patch, drupal-aggregator_refresh_routing-1972260-19.patch, failed testing.

ParisLiakos’s picture

Status: Needs work » Needs review
StatusFileSize
new762 bytes
new5.58 KB

ah we need absolute url

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Great stuff!

ParisLiakos’s picture

rerolled for the admin overview conversion

dawehner’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.phpundefined
@@ -31,6 +35,13 @@ class AggregatorController implements ControllerInterface {
+   /**
+   * Stores the current request.
+   *
+   * @var \Symfony\Component\HttpFoundation\Request
+   */
+  protected $request;

@@ -38,10 +49,13 @@ class AggregatorController implements ControllerInterface {
+  public function __construct(EntityManager $entity_manager, Connection $database, Request $request) {

Actually I realized that we don't need to store the request on the object. Controllers have the magic to pass in the request object, if specified in the controller method. Just try that out, it works. Fancy right?

ParisLiakos’s picture

you mean setRequest method? i dont understand what you tried

ParisLiakos’s picture

Status: Needs work » Needs review
StatusFileSize
new2.35 KB
new5.09 KB

ah i got it eventually...controller resolver does some nice tricks:) so if you add $request argument to your method it just works

ParisLiakos’s picture

Assigned: marcingy » ParisLiakos
StatusFileSize
new1.07 KB
new5.02 KB

hrmpff forgot the docblock

marcingy’s picture

Status: Needs review » Reviewed & tested by the community

Looks good

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 0a7825c and pushed to 8.x. Thanks!

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