class WebLinkExtension extends AbstractExtension

Twig extension for the Symfony WebLink component.

Methods

__construct(RequestStack $requestStack)

No description

getFunctions()

{@inheritdoc}

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

Adds a "Link" HTTP header.

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

Preloads a resource.

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

Resolves a resource origin as early as possible.

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

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

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

Indicates to the client that it should prefetch this resource.

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

Indicates to the client that it should prerender this resource .

Details

at line 29
__construct(RequestStack $requestStack)

Parameters

RequestStack $requestStack

at line 37
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. "['as' => true]", "['pr' => 0.5]")

Return Value

string The relation URI

at line 83
string preload(string $uri, array $attributes = [])

Preloads a resource.

Parameters

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

Return Value

string The path of the asset

at line 96
string dnsPrefetch(string $uri, array $attributes = [])

Resolves a resource origin as early as possible.

Parameters

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

Return Value

string The path of the asset

at line 109
string preconnect(string $uri, array $attributes = [])

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. "['as' => true]", "['pr' => 0.5]")

Return Value

string The path of the asset

at line 122
string prefetch(string $uri, array $attributes = [])

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. "['as' => true]", "['pr' => 0.5]")

Return Value

string The path of the asset

at line 135
string prerender(string $uri, array $attributes = [])

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. "['as' => true]", "['pr' => 0.5]")

Return Value

string The path of the asset