Skip to content

Commit

Permalink
FIX hechoendrupal#3556: Add urlRouteParameters function to the conten…
Browse files Browse the repository at this point in the history
…t entity class
  • Loading branch information
csegarra committed Dec 26, 2017
1 parent 23820bf commit 9d9c52f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions templates/module/src/Entity/entity-content.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition;
{% if revisionable %}
use Drupal\Core\Entity\RevisionableContentEntityBase;
use Drupal\Core\Entity\RevisionableInterface;
{% else %}
use Drupal\Core\Entity\ContentEntityBase;
{% endif %}
Expand Down Expand Up @@ -129,6 +130,22 @@ class {{ entity_class }} extends {% if revisionable %}RevisionableContentEntityB
}
{% if revisionable %}

/**
* {@inheritdoc}
*/
protected function urlRouteParameters($rel) {
$uri_route_parameters = parent::urlRouteParameters($rel);

if ($rel === 'revision_revert' && $this instanceof RevisionableInterface) {
$uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
}
elseif ($rel === 'revision_delete' && $this instanceof RevisionableInterface) {
$uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
}

return $uri_route_parameters;
}

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit 9d9c52f

Please sign in to comment.