You are here

protected function ConfigEntityRevisionsConfigEntityTrait::urlRouteParameters in Config Entity Revisions 8.2

Gets an array of placeholders for this entity.

Individual entity classes may override this method to add additional placeholders if desired. If so, they should be sure to replicate the property caching logic.

Parameters

string $rel: The link relationship type, for example: canonical or edit-form.

Return value

array An array of URI placeholders.

File

src/ConfigEntityRevisionsConfigEntityTrait.php, line 522

Class

ConfigEntityRevisionsConfigEntityTrait
Trait ConfigEntityRevisionsConfigEntityTrait.

Namespace

Drupal\config_entity_revisions

Code

protected function urlRouteParameters($rel) {
  $uri_route_parameters = [];
  if (!in_array($rel, [
    'collection',
    'add-page',
    'add-form',
  ], TRUE)) {

    // The entity ID is needed as a route parameter.
    $uri_route_parameters[$this
      ->getEntityTypeId()] = $this
      ->id();
  }
  if ($rel === 'add-form' && $this
    ->getEntityType()
    ->hasKey('bundle')) {
    $parameter_name = $this
      ->getEntityType()
      ->getBundleEntityType() ?: $this
      ->getEntityType()
      ->getKey('bundle');
    $uri_route_parameters[$parameter_name] = $this
      ->bundle();
  }
  if ($rel === 'revision' && $this instanceof RevisionableInterface) {
    $uri_route_parameters[$this
      ->getEntityTypeId() . '_revision'] = $this
      ->getRevisionId();
  }
  if (!is_null($this->loadedRevisionId)) {
    $uri_route_parameters += [
      'revision_id' => $this->loadedRevisionId,
    ];
  }
  return $uri_route_parameters;
}