@@ -183,18 +183,24 @@ You can also add links to the HTTP response directly from controllers and servic
183183 public function index(Request $request): Response
184184 {
185185 // using the addLink() shortcut provided by AbstractController
186- $this->addLink($request, (new Link(Link::REL_PRELOAD , '/app.css'))->withAttribute('as', 'style'));
186+ $this->addLink($request, (new Link('preload' , '/app.css'))->withAttribute('as', 'style'));
187187
188188 // alternative if you don't want to use the addLink() shortcut
189189 $linkProvider = $request->attributes->get('_links', new GenericLinkProvider());
190190 $request->attributes->set('_links', $linkProvider->withLink(
191- (new Link(Link::REL_PRELOAD , '/app.css'))->withAttribute('as', 'style')
191+ (new Link('preload' , '/app.css'))->withAttribute('as', 'style')
192192 ));
193193
194194 return $this->render('...');
195195 }
196196 }
197197
198+ .. tip ::
199+
200+ The possible values of link relations (``'preload' ``, ``'preconnect' ``, etc.)
201+ are also defined as constants in the :class: `Symfony\\ Component\\ WebLink\\ Link `
202+ class (e.g. ``Link::REL_PRELOAD ``, ``Link::REL_PRECONNECT ``, etc.).
203+
198204.. _`WebLink` : https://github.com/symfony/web-link
199205.. _`HTTP/2 Server Push` : https://tools.ietf.org/html/rfc7540#section-8.2
200206.. _`Resource Hints` : https://www.w3.org/TR/resource-hints/
0 commit comments