function Url::toRenderArray

Same name in other branches
  1. 9 core/lib/Drupal/Core/Url.php \Drupal\Core\Url::toRenderArray()
  2. 8.9.x core/lib/Drupal/Core/Url.php \Drupal\Core\Url::toRenderArray()

Returns the route information for a render array.

Return value

array An associative array suitable for a render array.

Deprecated

in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement.

See also

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

File

core/lib/Drupal/Core/Url.php, line 779

Class

Url
Defines an object that holds information about a URL.

Namespace

Drupal\Core

Code

public function toRenderArray() {
    @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3342977', E_USER_DEPRECATED);
    $render_array = [
        '#url' => $this,
        '#options' => $this->getOptions(),
    ];
    if (!$this->unrouted) {
        $render_array['#access_callback'] = [
            self::class,
            'renderAccess',
        ];
    }
    return $render_array;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.