Problem

  • Various config entity types neither declare a 'uri_callback' nor do they override the ::uri() method.
  • This prevents admin_menu from automatically expanding and exposing links to individual configuration items.

Related issues

Comments

sun’s picture

Issue tags: -API clean-up

drupal8.entity-uris.0.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +API clean-up

The last submitted patch, drupal8.entity-uris.0.patch, failed testing.

tim.plunkett’s picture

Also, from #1826602-122: Allow all configuration entities to be enabled/disabled

diff --git a/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php b/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php
index 5c4e69d..4235af3 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php
@@ -142,6 +142,10 @@ public function get($property_name, $langcode = NULL) {
   public function uri() {
     return array(
       'path' => 'admin/structure/views/view/' . $this->id(),
+      'options' => array(
+        'entity_type' => $this->entityType,
+        'entity' => $this,
+      ),
     );
   }
 
jibran’s picture

sun’s picture

Status: Needs work » Needs review

drupal8.entity-uris.0.patch queued for re-testing.

sun’s picture

StatusFileSize
new3.43 KB

OK, incorporated #3.

Would be lovely to move forward here :)

andypost’s picture

Status: Needs review » Needs work

Maybe better to document why we have to use "uri_callback" annotation (@see menu_entity_info_alter()) and overriden everywhere uri() method with absent sane parent implementation for example #1803586: Give all entities their own URI

+++ b/core/modules/filter/lib/Drupal/filter/Plugin/Core/Entity/FilterFormat.php
@@ -125,6 +125,19 @@ public function id() {
+      'path' => 'admin/config/content/formats/' . $this->id(),

+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Vocabulary.php
@@ -77,4 +77,18 @@ class Vocabulary extends ConfigEntityBase {
+      'path' => 'admin/structure/taxonomy/' . $this->id(),

+++ b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/Role.php
@@ -57,4 +57,17 @@ class Role extends ConfigEntityBase {
+      'path' => 'admin/people/roles/edit/' . $this->id(),

Looks like code-duplications. Maybe better to fix #1803586: Give all entities their own URI

+++ b/core/modules/user/user.module
@@ -985,6 +985,8 @@ function user_menu() {
+    'title callback' => 'entity_page_label',
+    'title arguments' => array(4),

+++ b/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php
@@ -151,6 +151,10 @@ public function get($property_name, $langcode = NULL) {
+      'options' => array(
+        'entity_type' => $this->entityType(),
+        'entity' => $this,

Looks like Needs tests for both cases

sun’s picture

Status: Needs work » Needs review

Maybe better to document why we have to use "uri_callback" annotation

Out of scope for this issue.

Looks like code-duplications. Maybe better to fix #1803586: Give all entities their own URI

Out of scope.

@@ -985,6 +985,8 @@ function user_menu() {
+ 'title callback' => 'entity_page_label',
+ 'title arguments' => array(4),

Looks like Needs tests

There is no way to test this in core, since Drupal core does not expose the menu item/link label for an administrative user role path anywhere.

The static 'title' and lack of a proper dynamic link label gets only exposed by admin_menu, which expands the dynamic routes into actual menu links, by generating the Cartesian product of registered dynamic routes and available config entity ID arguments.

fago’s picture

Status: Needs review » Needs work

This patch does not respect the uri-callback of those entity-types. What about following the way of the d7 entity module?
- Default to the callback Entity::defaultUri() in entity::uri()
- Default to NULL in the callback such that the default handling does not change
- Override defaultUri() for each entity type?

sun’s picture

Status: Needs work » Needs review

re: #9: That's not invented here.

fago’s picture

sun’s picture

Thanks! :)

So what's left here? Can we move forward?

sun’s picture

Issue tags: -API clean-up

#6: drupal8.entity-uris.6.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +API clean-up

The last submitted patch, drupal8.entity-uris.6.patch, failed testing.

sun’s picture

Status: Needs work » Needs review
StatusFileSize
new2.82 KB

#3 landed separately.

tim.plunkett’s picture

+++ b/core/modules/user/user.moduleundefined
@@ -990,6 +990,8 @@ function user_menu() {
+    'title callback' => 'entity_page_label',
+    'title arguments' => array(4),

I still don't get why this is in this issue. If it weren't for that hunk, it'd be RTBC. But that has nothing to do with Entity URIs from what I can see.

sun’s picture

Drupal core does not expose the menu item/link label for an administrative user role path anywhere.

The static 'title' and lack of a proper dynamic link label gets only exposed by admin_menu, which expands the dynamic routes into actual menu links, by generating the Cartesian product of registered dynamic routes and available config entity ID arguments.

sun’s picture

Any chance to move forward here? :)

andypost’s picture

StatusFileSize
new2.31 KB

@sun user_menu() hunk really out of scope of the issue. Role edit form shows "Edit role" title so file follow up for #1479454: Convert user roles to configurables

sun’s picture

Seriously. I'll create a new issue for that user_menu() hunk, but the pedantry is a little beyond me.

sun’s picture

Issue summary: View changes

Updated issue summary.

jibran’s picture

19: d.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 19: d.patch, failed testing.

gábor hojtsy’s picture

Is this issue still relevant? We put in annotations for these a while back.

andypost’s picture

Do we use annotations for config entities as well?
At least this issue could be used as clean-up for partially converted entities

gábor hojtsy’s picture

Indeed we do, see their code :)

gábor hojtsy’s picture

Issue summary: View changes
Status: Needs review » Closed (duplicate)
Related issues: +#2083615: Use links annotation for config entity URI like for content entities

Config translation is chock full of code and tests that are based on the edit-form annotations, so I think this is resolved. See http://drupalcode.org/project/config_translation.git/blob/refs/heads/8.x... where config entities are discovered based on their annotations and above where fields config entities are integrated (which do have a uri() callback instead of annotations since they derive their uri from their parent entities).

Tests ensuring these work are at http://drupalcode.org/project/config_translation.git/blob/refs/heads/8.x...

So marking this a duplicate of #2083615: Use links annotation for config entity URI like for content entities.