Part of #2285413: [Meta] Standardize entity route names, which is part of #2259445: Entity Resource unification

Standardize all taxonomy term entity route names to a standard format, as described below.

Problem/Motivation

Let's make any API changes now for the parent issue so that it doesn't block beta.

Proposed resolution

In order to get the API changes taken care of up-front for the parent issue, we are going to rename all of the entity-related routes to match what they will be once they are auto-generated. That way, once we start auto-generating them we can remove the static ones or not and there's no affect on module developers.

Remaining tasks

Rename all entity HTML routes to match a common format.

The common format is: entity.$entityname.$relationship, where $entityname is the machine name of the entity and $relationship is the relationship as defined in the entity annotation, machine-name-ified. (Convert - to _).

This requires a change to the entity annotation, the defined routes, and any generator calls to those routes.

User interface changes

None.

API changes

Many routes will have different names. Otherwise no change.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Crell’s picture

Issue summary: View changes
kgoel’s picture

Status: Active » Needs review
FileSize
5.87 KB

Status: Needs review » Needs work

The last submitted patch, 2: standardize-taxonomy-term-route-names-2291833-2.patch, failed testing.

kgoel’s picture

Status: Needs work » Needs review
FileSize
5.88 KB

Status: Needs review » Needs work

The last submitted patch, 4: standardize-taxonomy-term-route-names-2291833-4.patch, failed testing.

kgoel’s picture

Status: Needs work » Needs review
FileSize
5.21 KB
Crell’s picture

That's everything but canonical. Now for the hard one. :-)

kgoel’s picture

Canonical currently is -

*   links = {
 *     "canonical" = "taxonomy.term_page",
The common format is: $entityname.$relationship, where $entityname is the machine name of the entity and $relationship is the relationship as defined in the entity annotation, machine-name-ified. (Convert - to _). The one exception is "canonical", which should be named "page" in the route.

I don't think canonical needs to be change unless I am missing something.

Crell’s picture

It would be taxonomy_term.page, I believe. That's what the yet-to-be-written auto-generating logic would use. (Or whatever the machine name of taxonomy terms is.)

kgoel’s picture

kgoel’s picture

Issue summary: View changes
Crell’s picture

Issue summary: View changes
Status: Needs review » Needs work

Needs update for "canonical".

Crell’s picture

Title: [Meta] Standardize taxonomy term entity route names » Standardize taxonomy term entity route names
andypost’s picture

Status: Needs work » Needs review
FileSize
10.95 KB

Suppose proper approach.

Vocabulary 'add-form' link was broken, and added to Term new one

PS: no interdiff, because previous patch was mostly wrong

andypost’s picture

+++ b/core/modules/taxonomy/src/Entity/Term.php
@@ -43,10 +43,11 @@
+ *     "admin-form" = "entity.taxonomy_term.admin_form",

+++ b/core/modules/taxonomy/src/Entity/Vocabulary.php
@@ -35,11 +35,11 @@
+ *     "overview-form" = "entity.taxonomy_term.admin_form",

Here the admin form for terms is overview, imo that's fine

Status: Needs review » Needs work

The last submitted patch, 14: 2291833-14.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
FileSize
10.9 KB

add-form for Term needs vocabulary, so taxonomy_term_page() can't use the route

Status: Needs review » Needs work

The last submitted patch, 17: 2291833-17.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
FileSize
1.08 KB
11.98 KB

last place, reformatted code

Crell’s picture

+++ b/core/modules/taxonomy/src/Entity/Term.php
@@ -43,10 +43,10 @@
+ *     "admin-form" = "entity.taxonomy_term.admin_form",

The admin-form link should match the vocabulary's edit-form link for now. That was noted in the upper issues somewhere but didn't propagate out to the individuals, sorry. We can remove admin-form in #2309187: Fix double-link-entry between Entity and Entity Type classes.

Crell’s picture

Issue tags: +TCDrupal 2014
penyaskito’s picture

Status: Needs review » Needs work

I guess that means it needs work.

andypost’s picture

Status: Needs work » Needs review
FileSize
3.82 KB
12.05 KB

makes sense, this route is bound to vocabulary

andypost’s picture

otoh this route could be named entity.taxonomy_vocabulary.canonical

dawehner’s picture

+++ b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php
@@ -245,7 +245,11 @@ function testBreadCrumbs() {
-      $menu_links = entity_load_multiple_by_properties('menu_link_content', array('title' => $edit['title[0][value]'], 'route_name' => 'taxonomy.term_page', 'route_parameters' => serialize(array('taxonomy_term' => $term->id()))));
+      $menu_links = entity_load_multiple_by_properties('menu_link_content', array(
+        'title' => $edit['title[0][value]'],
+        'route_name' => 'entity.taxonomy_term.canonical',
+        'route_parameters' => serialize(array('taxonomy_term' => $term->id())),
+      ));

-1 for those changes, it is just much harder to review with --color-words!! Well, it already happened

+++ b/core/modules/taxonomy/src/Entity/Term.php
@@ -43,10 +43,10 @@
  *   links = {
...
+ *     "admin-form" = "entity.taxonomy_vocabulary.overview_form",

As we you said, in this case this method should be moved to the Vocabulary which then though conflicts with the field_ui local tasks

andypost’s picture

#25.2 - this would be moved to own annotation key in #2309187: Fix double-link-entry between Entity and Entity Type classes

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Okay, but please don't do that wrapping the future, if it is avoidable.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 23: 2291833-23.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
FileSize
12.04 KB

re-roll

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

re-rtbc

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. What are we doing with vocabulary's reset link?
    +++ b/core/modules/taxonomy/src/Entity/Vocabulary.php
    @@ -35,11 +35,11 @@
    - *     "add-form" = "taxonomy.term_add",
    - *     "delete-form" = "taxonomy.vocabulary_delete",
    + *     "add-form" = "entity.taxonomy_vocabulary.add_form",
    + *     "delete-form" = "entity.taxonomy_vocabulary.delete_form",
      *     "reset" = "taxonomy.vocabulary_reset",
    - *     "overview-form" = "taxonomy.overview_terms",
    - *     "edit-form" = "taxonomy.vocabulary_edit"
    + *     "overview-form" = "entity.taxonomy_vocabulary.overview_form",
    + *     "edit-form" = "entity.taxonomy_vocabulary.edit_form"
    

    The only link we're not changing is reset and there is no mention of why anywhere in the issue.

  2. +++ b/core/modules/taxonomy/src/Entity/Vocabulary.php
    @@ -35,11 +35,11 @@
    - *     "add-form" = "taxonomy.term_add",
    ...
    + *     "add-form" = "entity.taxonomy_vocabulary.add_form",
    

    This is not the same thing at all. This has broken the operations on VocabularyListBuilder since with this patch add terms now goes to the add vocabulary page :)

  3. +++ b/core/modules/taxonomy/taxonomy.links.action.yml
    @@ -1,11 +1,11 @@
     taxonomy_add_vocabulary_local_action:
    -  route_name: taxonomy.vocabulary_add
    +  route_name: entity.taxonomy_vocabulary.add_form
    ...
     taxonomy.term_add:
    -  route_name: taxonomy.term_add
    +  route_name: entity.taxonomy_term.add_form
    

    Let's make the action link names match.

  4. +++ b/core/modules/taxonomy/taxonomy.links.contextual.yml
    @@ -1,17 +1,17 @@
     taxonomy.term_edit:
    ...
    -  route_name: taxonomy.term_edit
    +  route_name: entity.taxonomy_term.edit_form
    ...
     taxonomy.term_delete:
    ...
    -  route_name: taxonomy.term_delete
    +  route_name: entity.taxonomy_term.delete_form
    ...
     taxonomy.vocabulary_delete:
    ...
    -  route_name: taxonomy.vocabulary_delete
    +  route_name: entity.taxonomy_vocabulary.delete_form
    

    Let's make the contextual link names match the route.

andypost’s picture

Status: Needs work » Needs review
FileSize
4.85 KB
14.49 KB

1) Converted to "reset-form" for consistency with other forms, also added test to ensure that after reset user is back to overview form
2) reverted, missed this... when we back to link templates it would be a bit clear then term route lives in vocabulary
3) fixed
4) fixed

Status: Needs review » Needs work

The last submitted patch, 32: 2291833-taxo-routes-32.patch, failed testing.

Status: Needs work » Needs review
penyaskito’s picture

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

I wanted to RTBC this, but does not apply anymore.

andypost’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
14.53 KB
+++ b/core/modules/taxonomy/src/Entity/Term.php
@@ -43,11 +43,11 @@
- *   field_ui_base_route = "taxonomy.overview_terms",
+ *   field_ui_base_route = "entity.taxonomy_term.admin_form",

+++ b/core/modules/taxonomy/src/Entity/Vocabulary.php
@@ -35,11 +35,11 @@
- *     "overview-form" = "taxonomy.overview_terms",
...
+ *     "overview-form" = "entity.taxonomy_term.admin_form",

still questional

andypost’s picture

FileSize
3.84 KB
14.61 KB

Suppose this name fits better

Crell’s picture

Status: Needs review » Reviewed & tested by the community

Then let's RTBC it. :-)

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 92ff387 and pushed to 8.0.x. Thanks!

  • alexpott committed 92ff387 on 8.0.x
    Issue #2291833 by andypost, kgoel | Crell: Standardize taxonomy term...

Status: Fixed » Closed (fixed)

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