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
- Write a patch
- Review
- 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.
Comment | File | Size | Author |
---|---|---|---|
#2 | jsonapi_extras-canonical-2978130-2.patch | 1.03 KB | idebr |
|
Comments
Comment #2
idebr CreditAttribution: idebr at ezCompany commentedThe attached patch implements the proposed solution to remove the canonical link template from the entity type annotation.
Comment #3
sonnyktComment #5
e0ipsoThis looks good! Thank you for the fix!