UrlService
class UrlService (View source)
Service for building absolute URLs
This service provides consistent URL building across the application, supporting both configured base URLs and auto-detection from HTTP headers.
Methods
Build an absolute URL from a relative path
Build an absolute URL for use inside outbound emails
Get the base URL for the application
Get the login page URL
Get a zone edit URL for use inside outbound emails
Details
__construct(ConfigurationInterface $config, LoggerInterface|null $logger = null)
No description
string
getAbsoluteUrl(string $path)
Build an absolute URL from a relative path
Priority order for base URL:
- Configured application_url (if set)
- A localhost base built from the detected protocol and base path prefix
string|null
getEmailUrl(string $path)
Build an absolute URL for use inside outbound emails
Only uses the configured interface.application_url. HTTP_HOST and other request-time headers are intentionally ignored so that an emailed link cannot be redirected by a forged Host header.
string
getBaseUrl()
Get the base URL for the application
Returns the full base URL including protocol, host, and base path prefix. Uses configured URL if available, otherwise auto-detects from server variables.
string
getLoginUrl()
Get the login page URL
Convenience method for building login URL.
string|null
getZoneEditUrl(int $zoneId)
Get a zone edit URL for use inside outbound emails