File tree 1 file changed +7
-0
lines changed
1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -147,13 +147,20 @@ You can also add links to the HTTP response directly from controllers and servic
147
147
{
148
148
public function index(Request $request)
149
149
{
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
150
154
$linkProvider = $request->attributes->get('_links', new GenericLinkProvider());
151
155
$request->attributes->set('_links', $linkProvider->withLink(new Link('preload', '/app.css')));
152
156
153
157
return $this->render('...');
154
158
}
155
159
}
156
160
161
+ .. versionadded :: 4.2
162
+ The ``addLink() `` shortcut was introduced in Symfony 4.2.
163
+
157
164
.. seealso ::
158
165
159
166
WebLink can be used :doc: `as a standalone PHP library </components/weblink >`
You can’t perform that action at this time.
0 commit comments