Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EntityBase.php

function EntityBase::urlRouteParameters

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.

5 calls to EntityBase::urlRouteParameters()
EntityBase::toUrl in core/lib/Drupal/Core/Entity/EntityBase.php
Gets the URL object for the entity.
EntityDisplayModeBase::urlRouteParameters in core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php
Gets an array of placeholders for this entity.
EntityDisplayModeBase::urlRouteParameters in core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php
Gets an array of placeholders for this entity.
FieldConfig::urlRouteParameters in core/modules/field/src/Entity/FieldConfig.php
Gets an array of placeholders for this entity.
FieldConfig::urlRouteParameters in core/modules/field/src/Entity/FieldConfig.php
Gets an array of placeholders for this entity.
2 methods override EntityBase::urlRouteParameters()
EntityDisplayModeBase::urlRouteParameters in core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php
Gets an array of placeholders for this entity.
FieldConfig::urlRouteParameters in core/modules/field/src/Entity/FieldConfig.php
Gets an array of placeholders for this entity.

File

core/lib/Drupal/Core/Entity/EntityBase.php, line 278

Class

EntityBase
Defines a base entity class.

Namespace

Drupal\Core\Entity

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 ($this instanceof RevisionableInterface && str_starts_with($rel, 'revision')) {
        $uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
    }
    return $uri_route_parameters;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal