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.
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.
Comment | File | Size | Author |
---|---|---|---|
#9 | drupal8.system-module.1987594-9.patch | 3.02 KB | disasm |
#9 | interdiff.txt | 1.41 KB | disasm |
#4 | system-theme_test-convert_to_controller-1987594-4.patch | 2.34 KB | mparker17 |
Comments
Comment #1
vijaycs85Need to rewrite the whole module to make test sync with current test implementation. For more details, please refer: #1988802: [META] Rewrite test modules in system to provide better unit testing.
Comment #2
ayelet_Cr CreditAttribution: ayelet_Cr commentedComment #3
mparker17I will help!
Comment #4
mparker17Try this...
Comment #5
dawehnerThis is nearly perfect!
Let's make the method public and return a render array.
Let's just drop the full menu item, as MENU_CALLBACK is not needed.
Comment #6
mparker17@dawehner, just two quick questions before I work on this...
1. I left the
hook_menu
item in because it had a'theme callback'
. Will returning a render array allow me to get around that?2. I'm not entirely sure how to return a render array in this circumstance because of the unusual call to
theme()
. Could I trouble you to provide me with an example?Thanks!
Comment #7
mparker17Ping...
Comment #8
disasm CreditAttribution: disasm commented#4: system-theme_test-convert_to_controller-1987594-4.patch queued for re-testing.
Comment #9
disasm CreditAttribution: disasm commentedDoing some git searches, I can't find any previous conversions that have:
a) removed a theme_callback
b) converted a theme() function with an array() as first parameter to a render array.
As such, my suggestion is to let this slide and get it committed where we can deal with refactoring a and b in a follow-up. The tricky thing with a is no one has addressed what theme_callback because in new routes that I know of. The tricky thing in b is the theme() function when it's an array uses the first available hook, and ignores the other parameter, so in the case of the following:
If the foo theme exists in the registry, it is used. If the foo theme does not exist, but the bar one does it is used. I am an un-aware of a #theme equivalent to this logic, and probably the whole thing should be refactored anyways.
Attached patch makes the methods public.
Comment #10
dawehnerSee title on the other review.
Comment #11
disasm CreditAttribution: disasm commentedI wrapped this into #1987870: Convert theme_test callbacks to a new style controller.
Comment #12
disasm CreditAttribution: disasm commented