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.
Sub-issue for meta issue #1880976: [meta] Port examples (including submodules) to D9.4+
Problem/Motivation
D8 all the things!
Proposed resolution
Start with D7 version and figure out how to port ;)
Comment | File | Size | Author |
---|---|---|---|
#30 | interdiff.txt | 1.24 KB | Mile23 |
#30 | 2102679_30.patch | 10.41 KB | Mile23 |
#26 | interdiff.txt | 5.61 KB | Mile23 |
#25 | 2102679_25.patch | 10.45 KB | Mile23 |
#17 | interdiff-2102679-17.txt | 11.31 KB | jjprieto |
Comments
Comment #1
jjprieto CreditAttribution: jjprieto commentedI will work on this.
Comment #2
Mile23Thanks a lot!
Check out the examples checklist: #2209627: [meta] Module Checklist for Examples
Comment #3
jjprieto CreditAttribution: jjprieto commentedAttached it is a first shot at tablesort_examples implemented in D8.
Comment #4
superspring CreditAttribution: superspring commentedComment #5
Mile23Thanks, @jjprieto!
Just a couple things...
If you check out the test result, you'll see that the test for tablesort_example never ran. :-) That's because it's not set up for PSR-4, so the test runner never found the tests.
Also, the menu links need to be defined in a .yml file. Some info here: https://www.drupal.org/node/2228089
Here's a patch with a PSR-4 conversion, and some standards formatting. Also, there was an extra controller called TableSortExample.php, which looked like a copy of the Block controller. I removed that since it was extraneous.
Thanks again.
Comment #7
jjprieto CreditAttribution: jjprieto commentedComment #8
jjprieto CreditAttribution: jjprieto commentedThanks @Mile23
I applied your recomendations.
I hope it is better this time
Comment #9
jjprieto CreditAttribution: jjprieto commentedComment #10
jjprieto CreditAttribution: jjprieto commentedComment #11
Mile23Thanks, @jjprieto. Here's some more. :-)
We need another test method for the path defined in *.menu_links.yml.
Look to phpunit_example for a template on how to do this: http://cgit.drupalcode.org/examples/tree/phpunit_example/src/Tests/PHPUn...
@file should just say that this file is the module file for tablesort_example.
The remaining narrative should be in the @defgroup block, and should explain the whats, whys, and hows of the example. Also, the @links should be @sees.
Hook_help() uses route names instead of paths now. https://www.drupal.org/node/2250345
But none of that matters, because we really should just remove hook_help() and put the information in the examples/tablesort_example page, in the controller. :-)
Comment #12
Mile23Comment #13
jjprieto CreditAttribution: jjprieto commentedOk thanks. I am going to work it
Comment #14
jjprieto CreditAttribution: jjprieto commentedHi, here I am again jeje.
1.- I changed the tablesort_Example.links.menu.yml (name) and I add the test.
2.- I think I explain the whats, whys, and hows of the example
3.- Deleted hook_help and it added to controller
Thanks a lot for your recomendations. they're very useful
Comment #16
jjprieto CreditAttribution: jjprieto commentedI am going to fix the patch
Comment #17
jjprieto CreditAttribution: jjprieto commentedSecond attempt
Comment #21
jjprieto CreditAttribution: jjprieto commentedSorry but I don't understand. Why did the test fail?
This test it isn't mine Drupal\config_entity_example\Tests\ConfigEntityExampleTest
It isn't at the patch. However my test is ok
Drupal\tablesort_example\Tests\TableSortExampleTest 27 0 0
Comment #22
Mile23Yes, the tests fail sometimes, especially for Drupal 8. They keep changing things..
Comment #23
Mile23Fixed the branch blocker here: http://cgit.drupalcode.org/examples/commit/?h=8.x-1.x&id=e95cae590b582e5...
Caused by #2305023: Rename getCancelRoute to getCancelUrl
Let's re-test.
Comment #25
Mile23Comment #26
Mile23Woops... forgot interdiff.
Comment #30
Mile23Fixed some formatting issues.
Comment #32
Mile23Committed and marked fixed.
Thanks, @jjprieto!