Entity annotation has inherited a reference to the legacy procedural URI callback in uri_callback key. In the same time there we are able to annotate the URI using the links = {"canonical" = "/entity/{entity}", ...}. See https://drupal.org/node/2020491

Deprecate the procedural callbacks.

Related issues

Comments

claudiu.cristea’s picture

From IRC:

[04:20am] claudiu_cristea: alexpott: xjm: (1) make url() use canonical (2) add links.canonical to all entities (3) deprecate procedural (4) remove url_callback key
[04:21am] xjm: (5) change notify it
...
[04:27am] claudiu_cristea: Hmm. What if an entity has bundle based URIs? Looking in url() this seems possible. How is the links {} stuff then?
[04:27am] xjm: claudiu_cristea: that's a good question
claudiu.cristea’s picture

Issue summary: View changes

Fix description.

claudiu.cristea’s picture

I'm back with some conclusion and proposals after researched a little bit.

  1. Bundle-based URIs are no more supported for content entities, starting from #1970360: Entities should define URI templates and standard links.
  2. Method url() was implemented to use link templates in EntityNG. So, all entities that are extending EntityNG and are defining link patterns are already using them. For those entities we can safely remove the url_callback annotation and drop the old procedural callback. Proposal: Remove uri_callback annotation and related procedural callbacks.
  3. There are no EntityNG based entities that are not defining link templates. A new hypothetical EntityNG not defining links will fallback to old uri_callback mechanism when calling ->uri() without parameters because of
    // For a canonical link (that is, a link to self), look up the stack for
    // default logic. Other relationship types are not supported by parent
    // classes.
    if ($rel == 'canonical') {
      return parent::uri();
    }
    

    That is looking up to parent Entity method that is still using uri_callback. Proposal: Break here the call to the legacy mechanism by replacing with:

    if ($rel == 'canonical') {
      return 'entity/' . $this->entityType . '/' . $this->id();
    }
    
  4. Configurables, that are based (via ConfigEntityBase) on Entity, are not inheriting the EntityNG new ->uri() method and are still using the procedural callback. Adopt one of next proposals:
    1. Add a ->uri() (that is using link templates) method to ConfigEntityBase and link templates in configurable annotations.
    2. Change the Entity::url() method to use new template links and annotate link templates in configurables.

Please comment on this.

larowlan’s picture

Um what happens to forum?
It needs bundle based urls for taxonomy terms.

xjm’s picture

Berdir’s picture

We have an existing issue for this, with discussions why this is a problem.

Crell’s picture

Berdir: Where? Should this issue be closed as a dupe?

Berdir’s picture

Yeah, sorry, did not have time to look it up. Here it is: #2010184: [meta] convert ‘uri_callback’ entities param to EntityInterface::uri() method. The biggest problem I think is that "Bundle-based URIs are no more supported for content entities" is correct for template-uris, but we actually *need* them in core, for forum. And yes of course should forums be a separate entity type and no, that won't happen in 8.x ;)

xjm’s picture

Status: Active » Closed (duplicate)

Yah, let's close this as a dupe and move the discussion over to #2010184: [meta] convert ‘uri_callback’ entities param to EntityInterface::uri() method.

xjm’s picture

Issue summary: View changes

Change summary.