When looking at this code, being part of LinksWidget.php in the buildListItems method:

      $items = [
        '#markup' => $link->toString(),
        '#wrapper_attributes' => [
          'class' => $classes,
        ],
        'children' => [$children_markup],
      ];

We are essentially rendering the Link already in the build method.

Feels like we are mixing up the build + the render phase? Asking if we can improve this :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dasjo created an issue. See original summary.

borisson_’s picture

Status: Active » Needs review
FileSize
741 bytes

I think we can, the integration test should pass, if all the tests pass this can go in. This is a great idea, thanks so much for the suggestion.

Status: Needs review » Needs work

The last submitted patch, 2: can_we_avoid_tostring-2696997-2.patch, failed testing.

The last submitted patch, 2: can_we_avoid_tostring-2696997-2.patch, failed testing.

marthinal’s picture

Status: Needs work » Needs review
FileSize
1.65 KB

@borisson_ @dasjo

If I understand correctly, the link should be built as an array in this phase(build).

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Sure, that sounds like a great idea.

  • marthinal committed 9cb3a2a on 8.x-1.x
    Issue #2696997 by borisson_, marthinal: Can we avoid toString() in build...
marthinal’s picture

Status: Reviewed & tested by the community » Fixed

Great! thanks guys

Status: Fixed » Closed (fixed)

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