Part of #1971384: [META] Convert page callbacks to controllers

For instructions on how to convert a page callback into a controller, see the WSCCI Conversion Guide.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

plopesc’s picture

Assigned: Unassigned » plopesc
Status: Active » Needs review
FileSize
2.77 KB

Hello

Attaching patch that converts shortcut_set_admin() to a Controller.

Regards.

dawehner’s picture

I really love to see all these route conversions going on!

+++ b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutController.phpundefined
@@ -0,0 +1,30 @@
+    return entity_list_controller('shortcut')->render();

One thing you could do is to inject the entity plugin manager into the controller. ('plugin.manager.entity') which has the getListController() method.

plopesc’s picture

Of course!

plopesc’s picture

FileSize
2.48 KB
3.29 KB

Re-rolling patch with dependency injection.

Regards.

dawehner’s picture

Thanks for fixing these points. Just think of a world where you can unit test all this code!

+++ b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutController.phpundefined
@@ -0,0 +1,48 @@
+   * Stores the Entity manager.
...
+   *   The Entity manager.

I looked for some examples and it always has been "the entity manager".

+++ b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutController.phpundefined
@@ -0,0 +1,48 @@
+   * Constructs a new \Drupal\views_ui\Routing\ViewsUIController object.

Sorry for the nitpick. Afaik the standard is "Constructs a $name object." ... You also create a shortcut controller here, not a viewsUI Controller :)

+++ b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutController.phpundefined
@@ -0,0 +1,48 @@
+    return $this->entityManager->getListcontroller('shortcut')->render();

Yeah PHP is odd from time to time. It allows you to call a method with wrong casing. The method is called getListController

plopesc’s picture

FileSize
3.37 KB

Thanks for your hard review.

Re-rolling again.

Regards.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for your patience.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed b5b34b1 and pushed to 8.x. Thanks!

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