Part of #2010184: [meta] convert ‘uri_callback’ entities param to EntityInterface::uri() method.

Needs to implement Plugin\Entity\MenuLink.php uri() method and drop menu_link_uri() function replacing it's calls to $entity->uri() and clean-up uri_callback at entity annotation.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kgoel’s picture

Assigned: Unassigned » kgoel
amateescu’s picture

Component: menu system » menu_link.module

Changed to the proper component.

kgoel’s picture

Status: Active » Needs review
FileSize
1.57 KB
garphy’s picture

FileSize
1.5 KB

Patch in #3 was not applying correctly anymore on HEAD. Rerolled.

rbayliss’s picture

Status: Needs review » Needs work
+++ b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.phpundefined
@@ -611,5 +610,16 @@ public function findParent(EntityStorageControllerInterface $storage_controller,
+  public function uri() {
+    return array(
+      'path' => '$menu_link->link_path' . $this->id(),
+      'options' => array(
+        'entity_type' => $this->entityType,
+        'entity' => $this,
+      )
+    );

This returns the literal text '$menu_link->link_path{ID}'. Path should just be $this->link_path (no quotes).

garphy’s picture

Well, actually I don't understand why @kgoel didn't use only $this->menu_link as in the original menu_link_uri() callback...
Why do we need to append any id to the path ?

rbayliss’s picture

Tthere is no reason to append an ID. Just $this->link_path is enough.

garphy’s picture

Status: Needs work » Needs review
FileSize
1.48 KB

Patch updated accordingly.

garphy’s picture

BTW, Entity::uri() now takes a $rel parameter and I'm not really sure about how to handle that.

Can't we eventually end up to directly use annotations on the MenuLink class to provide the right template ?

garphy’s picture

FileSize
1.48 KB

Fixed stupid $this mistake.

areke’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs reroll

This patch needs to be re-rolled because it no longer applies against the current HEAD.

benjy’s picture

Assigned: kgoel » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
1.51 KB

Re-rolled.

RainbowArray’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Patch no longer applies.

garphy’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
1.65 KB

Rerolled.

dawehner’s picture

+++ b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php
@@ -621,6 +620,19 @@ protected function findParent(EntityStorageControllerInterface $storage_controll
+    return array(
+      'path' => $this->link_path,

We should return 'route_name' and 'route_parameters' if available. For external links we still need to return the path.

garphy’s picture

Assigned: Unassigned » garphy
garphy’s picture

Status: Needs review » Needs work

Well... it seems that there's no more uri() method in Entity class, nor in EntityInterface so I'm a bit lost now.

Is it still "uri()" the right method to implement ?

dawehner’s picture

There is url().

garphy’s picture

Assigned: garphy » Unassigned
andypost’s picture

tim.plunkett’s picture

Priority: Normal » Major
Status: Needs work » Needs review
FileSize
2.71 KB

This is major until all URI callbacks are gone, since you cannot use the url() method with a callback if you have no templates.

Status: Needs review » Needs work

The last submitted patch, 21: menu_link-2010238-21.patch, failed testing.

Berdir’s picture

Status: Needs work » Closed (duplicate)

I think #2301319: MenuLinkNG part5: Remove dead code; and party! will remove this, so closing as duplicate.