File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 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
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 >`
You can’t perform that action at this time.
0 commit comments