Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cgalli’s picture

Status: Active » Needs review
FileSize
7.58 KB

Change in D8 Core: https://www.drupal.org/node/2382937

Changed links in the annotation and added links for view (canonical) and list (collection) for future use by core

Berdir’s picture

Status: Needs review » Needs work
  1. +++ b/content_entity_example/content_entity_example.links.menu.yml
    @@ -1,8 +1,8 @@
     
    -content_entity_example.contact_list:
    +entity.content_entity_example_contact.collection:
       title: 'Content Entity Example: Contacts Listing'
    

    This will become a standard with #2401505: Add an entity collection template for lists , so it makes sense to follow that pattern already.

  2. +++ b/content_entity_example/src/Entity/Controller/ContactListBuilder.php
    @@ -59,7 +59,7 @@ class ContactListBuilder extends EntityListBuilder {
         $row['name'] = \Drupal::l(
           $this->getLabel($entity),
    -      Url::fromRoute('content_entity_example.contact_view',
    +      Url::fromRoute('entity.content_entity_example_contact.canonical',
           array(
             'content_entity_example_contact' => $entity->id(),
           )
    

    As shown to @dasjo before, you can simplify this to $entity->link($this->getLabel($entity)), and even the getLabel() could be removed, because the only thing that is doing is a checkPlain(), which we get by default by making it a link. So, just $entity->link() is in fact enough.

cgalli’s picture

Status: Needs work » Needs review
FileSize
8.98 KB
2.47 KB

Shortened the link in listbuilder.

Added documentation for annotation link pattern

wesleydv’s picture

Status: Needs review » Reviewed & tested by the community

Tested and reviewed, seems ok to me

  • marvil07 committed d97335e on 8.x-1.x authored by cgalli
    Issue #2409195 by cgalli, Berdir: Content entity example: Rework link...
marvil07’s picture

Assigned: cgalli » Unassigned
Status: Reviewed & tested by the community » Fixed

Thanks for changes and suggestions.

Status: Fixed » Needs work

The last submitted patch, 3: annotation_links_2409195_3.patch, failed testing.

The last submitted patch, 1: annotation_links_2409195_2.patch, failed testing.

Berdir’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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