Comments

jhoelcq’s picture

Issue summary: View changes
StatusFileSize
new1.27 KB

An start version of the port.

mile23’s picture

Status: Active » Needs review

Thanks, @jhoelcq. If you set an issue to 'Needs review' the testbot will check your patch.

marvil07’s picture

Status: Needs review » Needs work

Back to NW.

mile23’s picture

Looks like a good start, but we need a lot more of the documentation and tests from the D7 version.

Converting the tests to D8 can help provide some structure, even if they fail.

Here's the Examples module checklist you can poke through for some guidance: #2209627: [meta] Module Checklist for Examples

marvil07’s picture

Issue summary: View changes
vijaycs85’s picture

Status: Needs work » Needs review
StatusFileSize
new7.17 KB
new6.42 KB

Here is the working version of the module. it covers what we have in core!.

vijaycs85’s picture

StatusFileSize
new68.75 KB

and a page for demo

mile23’s picture

Status: Needs review » Needs work

The patch applies, but trying to install comes back with this:

[18-Mar-2015 19:37:38 Europe/Berlin] PHP Fatal error:  Call to undefined function current_path() in /Users/paulmitchum/projects/drupal8/modules/examples/token_example/token_example.module on line 16

Looks like this is the relevant change: https://www.drupal.org/node/2382211

vijaycs85’s picture

Status: Needs work » Needs review
StatusFileSize
new6.12 KB
new1.54 KB

yep, updating to latest HEAD...

mile23’s picture

Status: Needs review » Needs work

Patch applies, and the module can be enabled, but there's no menu on the front page for examples/toolbar_example. When I visit that path, I get this fatal error:

03-Sep-2015 06:54:19 Europe/Berlin] PHP Fatal error:  Class 'Drupal\Component\Utility\String' not found in /Users/paulmitchum/projects/drupal8/modules/examples/token_example/token_example.module on line 81

So it at least needs a facelift to stop using String and start using SafeMarkup.

joshi.rohit100’s picture

Assigned: Unassigned » joshi.rohit100

Working on this.

joshi.rohit100’s picture

Status: Needs work » Needs review
StatusFileSize
new7.73 KB

Here it is.

joshi.rohit100’s picture

Assigned: joshi.rohit100 » Unassigned
mile23’s picture

Status: Needs review » Needs work

Looking better, just a few things:

  1. +++ b/token_example/src/Tests/TokenExampleTest.php
    @@ -0,0 +1,44 @@
    +/**
    + * @file
    + * SimpleTests for token_example module.
    + */
    

    Should be 'Contains...' style instead.

  2. +++ b/token_example/src/Tests/TokenExampleTest.php
    @@ -0,0 +1,44 @@
    +class ExamplesTest extends WebTestBase {
    +
    +  /**
    +   * Modules to install.
    +   *
    +   * @var array
    +   */
    +  public static $modules = array('examples', 'toolbar', 'token_example');
    +
    +  /**
    +   * Test for the token_example module tray.
    +   */
    +  public function testTokenExampleToolBar() {
    

    Maybe call it TokenExampleTest? :-)

    Also, we now have Drupal\examples\Tests\ExamplesTestBase to subclass. You'd use it because we also need a test of whether there's a link in the tool menu.

  3. +++ b/token_example/token_example.routing.yml
    @@ -0,0 +1,6 @@
    +token_example.example:
    

    Nice to have a routing file. Also needs a *.links.menu.yml file as well, so the link appears in the tool menu, with accompanying test.

joshi.rohit100’s picture

Assigned: Unassigned » joshi.rohit100

Aye Aye Captain :)

joshi.rohit100’s picture

Status: Needs work » Needs review
StatusFileSize
new8.07 KB
new1.06 KB

Status: Needs review » Needs work

The last submitted patch, 16: 2102685-16.patch, failed testing.

joshi.rohit100’s picture

It seems like if we use ExamplesTestBase as base for our test cases (as per #14), we need to enable block the block module.

Now I don't know if that we should do here in this issue or in separate issue (as current issue is only for token).

joshi.rohit100’s picture

Assigned: joshi.rohit100 » Unassigned
frob’s picture

I have queued a retest to see where we are with this 3 year old patch. Does anyone remember what is left on this issue? Looks like only tests holding it up.

mile23’s picture

Here's the checklist for examples: #2209627: [meta] Module Checklist for Examples

Needs: @defgroup/@ingroup annotation so it shows up at api.drupal.org

In-code documentation explaining what everything is, why you'd need it, what it does. This is especially true in hook_tokens() which is the most complicated part of the code.

Test that the token actually works.

Many occurrences of array() which should be [].

Probably other stuff...

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new10.65 KB
new9.5 KB

CS improvements.

Added @defgroup, @ingroup.

TokenExampleTest is now WTB.

Added a Kernel test for the tokens themselves.

Still needs:

  • @defgroup docblock explaining everything.
  • Lots more inline comments in hook_token()
  • More info on the description page.
  • Show the tags on the description page, so we can see what was replaced.
mile23’s picture

Status: Needs review » Needs work

NW based on #22.

joshi.rohit100’s picture

Is it fine to use *.module file to token hooks? I mean it will work but I think this should be in *.token.inc

mile23’s picture

Status: Needs work » Needs review

A bit of re-arranging.

Still needs more inline stuff in the @defgroup docblock.
Expand on the twig description stuff.

I'm still not sure what we're demonstrating with 'token_example_type'.

If anyone wants to jump in, please give it a go. :-)

mile23’s picture

StatusFileSize
new13.21 KB
new9.31 KB

Might help to include the patch.

jungle’s picture

Title: Port token_example module to Drupal 8 » Port token_example module to Drupal 9
Version: 8.x-1.x-dev » 3.x-dev

The default branch is 3.x-dev now, which is Drupal 9 compatible. And I would port this to Drupal 9. :)

avpaderno’s picture

Version: 3.x-dev » 4.0.x-dev
Component: Token Example » Code
avpaderno’s picture

Title: Port token_example module to Drupal 9 » Port token_example module to Drupal 11.4
Component: Code » New modules
avpaderno’s picture

Version: 4.0.x-dev » 5.0.x-dev
Status: Needs review » Postponed
avpaderno’s picture