WebLinkExtension

class WebLinkExtension extends AbstractExtension

Twig extension for the Symfony WebLink component.

Methods

__construct(RequestStack $requestStack)
getFunctions()

{@inheritdoc}

string link(string $uri, string $rel, array $attributes = array())

Adds a "Link" HTTP header.

string preload(string $uri, array $attributes = array())

Preloads a resource.

string dnsPrefetch(string $uri, array $attributes = array())

Resolves a resource origin as early as possible.

string preconnect(string $uri, array $attributes = array())

Initiates a early connection to a resource (DNS resolution, TCP handshake, TLS negotiation).

string prefetch(string $uri, array $attributes = array())

Indicates to the client that it should prefetch this resource.

string prerender(string $uri, array $attributes = array())

Indicates to the client that it should prerender this resource .

Details

__construct(RequestStack $requestStack)

Parameters

RequestStack $requestStack

getFunctions()

{@inheritdoc}

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)")

Return Value

string The relation URI

string preload(string $uri, array $attributes = array())

Preloads a resource.

Parameters

string $uri A public path
array $attributes The attributes of this link (e.g. "array('as' => true)", "array('crossorigin' => 'use-credentials')")

Return Value

string The path of the asset

string dnsPrefetch(string $uri, array $attributes = array())

Resolves a resource origin as early as possible.

Parameters

string $uri A public path
array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")

Return Value

string The path of the asset

string preconnect(string $uri, array $attributes = array())

Initiates a early connection to a resource (DNS resolution, TCP handshake, TLS negotiation).

Parameters

string $uri A public path
array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")

Return Value

string The path of the asset

string prefetch(string $uri, array $attributes = array())

Indicates to the client that it should prefetch this resource.

Parameters

string $uri A public path
array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")

Return Value

string The path of the asset

string prerender(string $uri, array $attributes = array())

Indicates to the client that it should prerender this resource .

Parameters

string $uri A public path
array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")

Return Value

string The path of the asset

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/4.0/Symfony/Bridge/Twig/Extension/WebLinkExtension.html