You are here

public function ConfigPages::urlInfo in Config Pages 8

Gets the URL object for the entity.

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.

Overrides EntityBase::urlInfo

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityInterface::toUrl() instead.

See also

https://www.drupal.org/node/2614344

\Drupal\Core\Entity\EntityInterface::toUrl

File

src/Entity/ConfigPages.php, line 201

Class

ConfigPages
Defines the config page entity class.

Namespace

Drupal\config_pages\Entity

Code

public function urlInfo($rel = 'canonical', array $options = []) {
  $config_pages_type = ConfigPagesType::load($this
    ->bundle());
  $menu = $config_pages_type
    ->get('menu');
  $path = isset($menu['path']) ? $menu['path'] : '';
  return $path ? Url::fromRoute('config_pages.' . $this
    ->bundle(), [
    'config_pages' => $this
      ->id(),
  ]) : Url::fromRoute('entity.config_pages.canonical', [
    'config_pages' => $this
      ->id(),
  ]);
}