Problem/Motivation
Canonical link for simple block entity is declared in class SimpleBlock annotation:
* "canonical" = "/admin/structure/block/simple-block/manage/{simple_block}",
but route is not defined anywhere in module.
This could lead to errors if other modules make use of method toUrl() of a simple block entity.
For example, this code taken from responsive theme preview (https://www.drupal.org/project/responsive_preview)
...
if ($entity->hasLinkTemplate('canonical')) {
return $entity->toUrl()->toString();
}
...
while condition is always TRUE for simple block entities, $entity->toUrl() returns this error:
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "entity.simple_block.canonical" does not exist
Proposed resolution
Simply remove canonical link in entity annotation.
Remaining tasks
None
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | simple_block-canonical_link_is_declared_but_not_defined-3418143-2.patch | 881 bytes | maurizio.ganovelli |
Issue fork simple_block-3418143
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
maurizio.ganovelliAttached patch removes canonical link annotation.
Comment #3
maurizio.ganovelliMaybe this issue could be related (same error): When a simple block is deleted, it causes an RouteNotFoundException.
Comment #7
astonvictor commentedHi @maurizio.ganovelli,
thanks for the patch. Changes will be added in the next release.
Comment #8
maurizio.ganovelliGreat, thanks!
Comment #9
astonvictor commented