Back to PreloadManager class

Method link

private void
(string $uri, string $rel, array $attributes = [])
Adds a "Link" HTTP header.
Parameters
  • string $uri The relation URI
  • string $rel The relation type (e.g. "preload", "prefetch", "prerender" or "dns-prefetch")
  • array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")
Returns
  • void
Since
  • 4.0.0

Method link - Source code

/**
 * Adds a "Link" HTTP header.
 *
 * @param   string  $uri         The relation URI
 * @param   string  $rel         The relation type (e.g. "preload", "prefetch", "prerender" or "dns-prefetch")
 * @param   array   $attributes  The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")
 *
 * @return  void
 *
 * @since   4.0.0
 */
private function link(string $uri, string $rel, array $attributes = [])
{
    $link = new Link($rel, $uri);
    foreach ($attributes as $key => $value) {
        $link = $link->withAttribute($key, $value);
    }
    $this->setLinkProvider($this->getLinkProvider()->withLink($link));
}