File tree Expand file tree Collapse file tree 2 files changed +18
-9
lines changed Expand file tree Collapse file tree 2 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -784,18 +784,23 @@ The following example shows how to detect if the user agent prefers "safe" conte
784784
785785 return $response;
786786
787- UrlHelper
788- -------
787+ Generating Relative and Absolute URLs
788+ -------------------------------------
789789
790- Generating absolute (and relative) URLs for a given path is a common need
791- in lots of applications. In Twig templates this is trivial thanks to the
792- absolute_url() and relative_path() functions. The same functionality can
793- be found in the :class: `Symfony\\ Component\\ HttpFoundation\\ UrlHelper ` class,
794- which can be injected as a service anywhere in your application. This class
795- provides two public methods called getAbsoluteUrl() and getRelativePath()::
790+ .. versionadded :: 5.4
796791
797- // src/Normalizer/UserApiNormalizer.php
792+ The feature to generate relative and absolute URLs was introduced in Symfony 5.4.
793+
794+ Generating absolute and relative URLs for a given path is a common need
795+ in some applications. In Twig templates you can use the
796+ :ref: `absolute_url() <reference-twig-function-absolute-url >` and
797+ :ref: `relative_path() <reference-twig-function-relative-path >` functions to do that.
798798
799+ The :class: `Symfony\\ Component\\ HttpFoundation\\ UrlHelper ` class provides the
800+ same functionality for PHP code via the ``getAbsoluteUrl() `` and ``getRelativePath() ``
801+ methods. You can inject this as a service anywhere in your application::
802+
803+ // src/Normalizer/UserApiNormalizer.php
799804 namespace App\Normalizer;
800805
801806 use Symfony\Component\HttpFoundation\UrlHelper;
Original file line number Diff line number Diff line change @@ -225,6 +225,8 @@ Returns the absolute URL (with scheme and host) for the given route. If
225225 Read more about :doc: `Symfony routing </routing >` and about
226226 :ref: `creating links in Twig templates <templates-link-to-pages >`.
227227
228+ .. _reference-twig-function-absolute-url :
229+
228230absolute_url
229231~~~~~~~~~~~~
230232
@@ -239,6 +241,8 @@ Returns the absolute URL (with scheme and host) from the passed relative path. C
239241:ref: `asset() function <reference-twig-function-asset >` to generate absolute URLs
240242for web assets. Read more about :ref: `Linking to CSS, JavaScript and Image Assets <templates-link-to-assets >`.
241243
244+ .. _reference-twig-function-relative-path :
245+
242246relative_path
243247~~~~~~~~~~~~~
244248
You can’t perform that action at this time.
0 commit comments