8.4.x ConfigEntityBase.php public ConfigEntityBase::toUrl($rel = 'edit-form', array $options = [])
8.0.x ConfigEntityBase.php public ConfigEntityBase::toUrl($rel = 'edit-form', array $options = [])
8.1.x ConfigEntityBase.php public ConfigEntityBase::toUrl($rel = 'edit-form', array $options = [])
8.2.x ConfigEntityBase.php public ConfigEntityBase::toUrl($rel = 'edit-form', array $options = [])
8.3.x ConfigEntityBase.php public ConfigEntityBase::toUrl($rel = 'edit-form', array $options = [])
8.5.x ConfigEntityBase.php ConfigEntityBase::toUrl($rel = 'edit-form', array $options = [])

Gets the URL object for the entity.

The entity must have an id already. Content entities usually get their IDs by saving them.

URI templates might be set in the links array in an annotation, for example:

links = {
  "canonical" = "/node/{node}",
  "edit-form" = "/node/{node}/edit",
  "version-history" = "/node/{node}/revisions"
}

or specified in a callback function set like:

uri_callback = "comment_uri",

If the path is not set in the links array, the uri_callback function is used for setting the path. If this does not exist and the link relationship type is canonical, the path is set using the default template: entity/entityType/id.

Parameters

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

array $options: See \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute() for the available options.

Return value

\Drupal\Core\Url The URL object.

Throws

\Drupal\Core\Entity\EntityMalformedException

\Drupal\Core\Entity\Exception\UndefinedLinkTemplateException

Overrides Entity::toUrl

File

core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php, line 430

Class

ConfigEntityBase
Defines a base configuration entity class.

Namespace

Drupal\Core\Config\Entity

Code

public function toUrl($rel = 'edit-form', array $options = []) {
  // Unless language was already provided, avoid setting an explicit language.
  $options += ['language' => NULL];
  return parent::toUrl($rel, $options);
}