CurrentUrlTrait
Absolute address of the current page for meta and OG data (`url`, `og:url`) and for links the page sends out (the recommend form).
The address start comes from the site.baseUrl setting (SiteBaseUrl); an empty setting
falls back to the request address.
Table of Contents
Properties
- $siteBaseUrl : SiteBaseUrl
- Website address for links outside the request; public because components use it (`MessageInfoLine`).
Methods
- currentAbsoluteUrl() : string
- Returns `link('//this')`, or the request address without query when it cannot be built.
Properties
$siteBaseUrl
Website address for links outside the request; public because components use it (`MessageInfoLine`).
public
SiteBaseUrl
$siteBaseUrl
Attributes
- #[Inject]
Methods
currentAbsoluteUrl()
Returns `link('//this')`, or the request address without query when it cannot be built.
protected
currentAbsoluteUrl() : string
IMPORTANT: it is called from startup() of every front page (MetaDataInitTrait,
OgDataInitTrait), before Nette verifies the required action parameters. A request
without them (/editace-firmy without id for actionEdit(int $id)) should end as a 404,
but link('//this') reports an invalid link there; in debug mode that is an E_USER_WARNING
which Tracy (strict mode) turns into a 500 that catch cannot catch. So InvalidLinkException
is forced for the duration of the call and the mode is restored in finally (same principle
as SafeLinkExtension::generateSafeLink(), which cannot
handle the //this target because it verifies that the target presenter exists).