Entity link templates with dynamic parameters don't work

Created on 2 April 2021, about 4 years ago
Updated 21 March 2023, about 2 years ago

Problem/Motivation

Through a combination of \Drupal\recurly\Routing\RecurlyRouteSubscriber, and \Drupal\recurly\RecurlyEntityTypeInfo::entityTypeAlter this module adds link templates like "recurly-cancel" that map to routes like /user/{uid}/subscription/id/{subscription_id}/cancel. But, these don't work when you try and access them via the $entity->toUrl('recurly-cancel') it won't work because the {subscription_id} parameter will be empty.

The routes themselves work as expected, like if you go to /user/9/subscription/id/123-456-ASDF-HJK/cancel, the page loads and works. But the entity link templates do not.

I'm not sure if there is a way to fix this or not. So far I haven't been able to figure it out. But we should either fix these link template, or remove them.

This list includes:

  • recurly-planchange = /subscription/id/{subscription_id}/change/{new_plan_code}
  • recurly-cancel = /subscription/id/{subscription_id}/cancel
  • recurly-reactivate = /subscription/id/{subscription_id}/reactivate
  • recurly-invoice = /subscription/invoices/{invoice_number}
  • recurly-invoicepdf = /subscription/invoices/{invoice_number}/pdf

Steps to reproduce

Load an entity with a recurly subscription, and then try and use the ::toUrl() method on one of the link templates above.

e.g.

$account->toUrl('recurly-cancel');

I haven't found anything in the module that's not working as a result of this. In fact, none of these link templates are actually used anywhere in the module. The module always does something like:

$path = '/user/' . $account->id() . '/subscription/invoices/' . $invoice->id;

So maybe the easiest thing to do would be to just remove them?

πŸ› Bug report
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States eojthebrave Minneapolis, MN

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024