Problem/Motivation

The JSON API Resource Config entity type defines a canonical link template in the entity type annotation:

/**
 * Defines the JSON API Resource Config entity.
 * 
 * ....
 *   links = {
 *     "canonical" = "/admin/config/services/jsonapi/{jsonapi_resource_config}",
 *     "add-form" = "/admin/config/services/jsonapi/add/{entity_type_id}/{bundle}",
 *     "edit-form" = "/admin/config/services/jsonapi/{jsonapi_resource_config}/edit",
 *     "delete-form" = "/admin/config/services/jsonapi/{jsonapi_resource_config}/delete",
 *     "collection" = "/admin/config/services/jsonapi"
 *   }
 * )
 */
class JsonapiResourceConfig extends ConfigEntityBase {

The associated route is added conditionally by Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider::getRoutes:

    if ($canonical_route = $this->getCanonicalRoute($entity_type)) {
      $collection->add("entity.{$entity_type_id}.canonical", $canonical_route);
    }

However, the entity type does not list a view_builder handler, so the DefaultHtmlRouteProvider does not generate a route for the entity type:

  protected function getCanonicalRoute(EntityTypeInterface $entity_type) {
    if ($entity_type->hasLinkTemplate('canonical') && $entity_type->hasViewBuilderClass()) {
    }
  }

Proposed resolution

Considering there is no real use case for a canonical page for the JSON API Resource Config entity type, remove the canonical link template from the JSON API Resource Config entity type annotation.

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None.

API changes

None.

Data model changes

The JSON API Resource Config entity type no longer defines a canonical link template.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

idebr created an issue. See original summary.

idebr’s picture

Title: JSON API Resource Config define a canonical link template but does not have a canonical route » JSON API Resource Config defines a canonical link template but does not have a canonical route
Status: Active » Needs review
FileSize
1.03 KB

The attached patch implements the proposed solution to remove the canonical link template from the entity type annotation.

sonnykt’s picture

Status: Needs review » Reviewed & tested by the community

  • e0ipso committed 40f1300 on 8.x-2.x authored by idebr
    Issue #2978130 by idebr, sonnykt: JSON API Resource Config defines a...
e0ipso’s picture

Status: Reviewed & tested by the community » Fixed

This looks good! Thank you for the fix!

Status: Fixed » Closed (fixed)

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