I'm not certain if I'm over-complicating something or just missing something or other.
Essentially, and in addition to a separate admin view of my custom entities, I want to assign a URL to them at the root of the site (i.e. /entity01).
I tried creating a URL property, but getting a route to respond to that is proving challenging. I tried adding a route like:
my_entities.entity_page:
path: '/{entity_url}'
defaults:
_controller: '\Drupal\my_module\Controller\MyController::view'
_title: 'Hello'
options:
parameters:
entity_url:
type: entity_url
requirements:
_permission: 'access content'
I have a custom a custom parameter converter set up as in:
https://www.drupal.org/docs/8/api/routing-system/implementing-custom-parameter-converters
... and in the convert
method, I can use an injected service to load my entity, etc. But in the applies
method, I would like to see if it even matches any of my entities and return true or false appropriately, but the applies
method doesn't seem to have the value of the URL parameter like the convert
method does.
And even if I solve that, the above example only works with a path like:
path: '/my/{entity_url}'
If I remove the /my
it doesn't work - I assume because it is conflicting with another route?
Thanks for any help!