8000 Documented the addLink() shortcut · symfony/symfony-docs@26817be · GitHub
[go: up one dir, main page]

Skip to content

Commit 26817be

Browse files
committed
Documented the addLink() shortcut
1 parent 4fc5a88 commit 26817be

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

weblink.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,20 @@ You can also add links to the HTTP response directly from controllers and servic
147147
{
148148
public function index(Request $request)
149149
{
150+
// using the addLink() shortcut provided by AbstractController
151+
$this->addLink($request, new Link('preload', '/app.css'));
152+
153+
// alternative if you don't want to use the addLink() shortcut
150154
$linkProvider = $request->attributes->get('_links', new GenericLinkProvider());
151155
$request->attributes->set('_links', $linkProvider->withLink(new Link('preload', '/app.css')));
152156

153157
return $this->render('...');
154158
}
155159
}
156160

161+
.. versionadded:: 4.2
162+
The ``addLink()`` shortcut was introduced in Symfony 4.2.
163+
157164
.. seealso::
158165

159166
WebLink can be used :doc:`as a standalone PHP library </components/weblink>`

0 commit comments

Comments
 (0)
0