10000 minor #10621 Documented the addLink() shortcut (javiereguiluz) · symfony/symfony-docs@0e697b2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0e697b2

Browse files
committed
minor #10621 Documented the addLink() shortcut (javiereguiluz)
This PR was merged into the master branch. Discussion ---------- Documented the addLink() shortcut This fixes #10612 and #10564. Commits ------- 26817be Documented the addLink() shortcut
2 parents 4fc5a88 + 26817be commit 0e697b2

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