dpi / rng

RNG is a Drupal module enabling people to register for events.
https://www.drupal.org/project/rng
GNU General Public License v2.0
15 stars 23 forks source link

RegistrationType: canonical URL fails even though type exists #164

Closed rtrvrtg closed 6 years ago

rtrvrtg commented 6 years ago

Here's a test I did in drush php (with identifying info changed):

>>> $e = entity_load('registration_type', 'foo')
=> Drupal\rng\Entity\RegistrationType {#1535
     +id: "foo",
     +label: "Foo",
     +description: "Foo Signup",
     #uuid: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
     #langcode: "en",
     #status: true,
     #dependencies: [],
     #label: "Foo",
     #id: "foo",
     #description: "Foo Signup",
   }
>>> $e->getEntityType()->getLinkTemplates()
=> [
     "canonical" => "/admin/structure/rng/registration_types/manage/{registration_type}",
     "edit-form" => "/admin/structure/rng/registration_types/manage/{registration_type}",
     "delete-form" => "/admin/structure/rng/registration_types/manage/{registration_type}/delete",
   ]
>>> $e->url('canonical')
Symfony\Component\Routing\Exception\RouteNotFoundException with message 'Route "entity.registration_type.canonical" does not exist.'

This has been stuffing me around because I've been needing to serialise my registrations, and no matter what I do, it throws this mysterious RouteNotFoundException. Here's more info on how I tried to fix it in Serialization module: https://www.drupal.org/project/drupal/issues/2941332

dpi commented 6 years ago

Just a heads up, \Drupal\Core\Config\Entity\ConfigEntityBase::url has a default $rel param value of 'edit-form'. So its probably best to leave the param value empty if you want the most-default url.

The fact that canonical is an undefined route will be fixed however.