From 26817be20824db86ce216deb9634a3014d7612ee Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 31 Oct 2018 10:03:09 +0100 Subject: [PATCH] Documented the addLink() shortcut --- weblink.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/weblink.rst b/weblink.rst index 8621357c656..384cd691490 100644 --- a/weblink.rst +++ b/weblink.rst @@ -147,6 +147,10 @@ You can also add links to the HTTP response directly from controllers and servic { public function index(Request $request) { + // using the addLink() shortcut provided by AbstractController + $this->addLink($request, new Link('preload', '/app.css')); + + // alternative if you don't want to use the addLink() shortcut $linkProvider = $request->attributes->get('_links', new GenericLinkProvider()); $request->attributes->set('_links', $linkProvider->withLink(new Link('preload', '/app.css'))); @@ -154,6 +158,9 @@ You can also add links to the HTTP response directly from controllers and servic } } +.. versionadded:: 4.2 + The ``addLink()`` shortcut was introduced in Symfony 4.2. + .. seealso:: WebLink can be used :doc:`as a standalone PHP library `