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 ;)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jjprieto’s picture

Assigned: Unassigned » jjprieto
Issue summary: View changes

I will work on this.

Mile23’s picture

Thanks a lot!

Check out the examples checklist: #2209627: [meta] Module Checklist for Examples

jjprieto’s picture

FileSize
14.57 KB

Attached it is a first shot at tablesort_examples implemented in D8.

superspring’s picture

Assigned: jjprieto » Unassigned
Status: Active » Needs review
Mile23’s picture

FileSize
8.92 KB
12.16 KB

Thanks, @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.

Status: Needs review » Needs work

The last submitted patch, 5: 2102679_5.patch, failed testing.

jjprieto’s picture

Assigned: Unassigned » jjprieto
Status: Needs work » Active
jjprieto’s picture

FileSize
11.52 KB
10.21 KB

Thanks @Mile23
I applied your recomendations.

I hope it is better this time

jjprieto’s picture

Status: Active » Needs review
jjprieto’s picture

Assigned: jjprieto » Unassigned
Mile23’s picture

Thanks, @jjprieto. Here's some more. :-)

  1. +++ b/modules/examples/tablesort_example/src/Tests/TableSortExampleTest.php
    @@ -0,0 +1,98 @@
    +class TableSortExampleTest extends WebTestBase {
    

    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...

  2. +++ b/modules/examples/tablesort_example/tablesort_example.module
    @@ -0,0 +1,34 @@
    +/**
    + * @file
    + * This is an example describing how a module can display data in a sortable
    + * table
    + *
    + * See:
    + * @link http://drupal.org/node/508796 Extenders @endlink
    + * @link http://drupal.org/developing/api/database Database API @endlink
    + */
    +
    +/**
    + * @defgroup tablesort_example Example: Tablesort
    + * @ingroup examples
    + * @{
    + * Example of a sortable table display.
    + */
    

    @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.

  3. +++ b/modules/examples/tablesort_example/tablesort_example.module
    @@ -0,0 +1,34 @@
    +function tablesort_example_help($path, $arg) {
    

    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. :-)

Mile23’s picture

Status: Needs review » Needs work
jjprieto’s picture

Assigned: Unassigned » jjprieto
Status: Needs work » Active

Ok thanks. I am going to work it

jjprieto’s picture

Assigned: jjprieto » Unassigned
Status: Active » Needs review
FileSize
8.17 KB
5.54 KB

Hi, 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

Status: Needs review » Needs work

The last submitted patch, 14: 2102679_14.patch, failed testing.

jjprieto’s picture

Assigned: Unassigned » jjprieto
Status: Needs work » Active

I am going to fix the patch

jjprieto’s picture

Assigned: jjprieto » Unassigned
Status: Active » Needs review
FileSize
12.65 KB
11.31 KB

Second attempt

Status: Needs review » Needs work

The last submitted patch, 17: 2102679_17.patch, failed testing.

jjprieto queued 17: 2102679_17.patch for re-testing.

The last submitted patch, 17: 2102679_17.patch, failed testing.

jjprieto’s picture

Status: Needs work » Needs review

Sorry 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

Mile23’s picture

Yes, the tests fail sometimes, especially for Drupal 8. They keep changing things..

Mile23’s picture

Mile23 queued 17: 2102679_17.patch for re-testing.

Mile23’s picture

FileSize
10.45 KB
Mile23’s picture

FileSize
5.61 KB

Woops... forgot interdiff.

Mile23 queued 25: 2102679_25.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 25: 2102679_25.patch, failed testing.

Mile23 queued 25: 2102679_25.patch for re-testing.

Mile23’s picture

Status: Needs work » Needs review
FileSize
10.41 KB
1.24 KB

Fixed some formatting issues.

  • Mile23 committed be74b0e on 8.x-1.x authored by jjprieto
    Issue #2102679 by jjprieto, Mile23 | Kristen Pol: Port tablesort_example...
Mile23’s picture

Status: Needs review » Fixed

Committed and marked fixed.

Thanks, @jjprieto!

Status: Fixed » Closed (fixed)

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