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

Command icon 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

maurizio.ganovelli created an issue. See original summary.

maurizio.ganovelli’s picture

Status: Active » Needs review
StatusFileSize
new881 bytes

Attached patch removes canonical link annotation.

maurizio.ganovelli’s picture

AstonVictor made their first commit to this issue’s fork.

astonvictor’s picture

Status: Needs review » Fixed

Hi @maurizio.ganovelli,

thanks for the patch. Changes will be added in the next release.

maurizio.ganovelli’s picture

Great, thanks!

astonvictor’s picture

Status: Fixed » Closed (fixed)