Problem/Motivation
Give a $entity, how to generate the API-path of it?
'/ce-api/' . $entity->toUrl() works but is not exactly nice or flexible.
/ce-api might change, and integration modules might alter the API for a given $entity in a multi-frontend scenariou.
Proposed resolution
$entity->toUrl('canonical', ['ce_api' => TRUE]
or
$entity->toUrl('canonical', ['_format' => 'custom_elements']
Comments
Comment #2
fagoComment #3
fagoComment #4
useernamee commentedI checked into this issue and did not find a nice way to hook into the toUrl method https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...
Maybe I wasn't thorough enough but $options parameter on UrlGeneratorInterface seem to be defined in advance: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Routing%2...