CRM_Utils_Url
in package
Table of Contents
Methods
- isChildOf() : bool
- Determine if $child is a descendent of $parent.
- parseInternalRoute() : array<string|int, mixed>
- Parse an internal URL. Extract the CiviCRM route.
- parseUrl() : UriInterface
- Parse url to a UriInterface.
- toAbsolute() : string
- Convert to an absolute URL (if relative).
- toRelative() : string
- Convert to a relative URL (if host/port matches).
- unparseUrl() : string
- Unparse url back to a string.
Methods
isChildOf()
Determine if $child is a descendent of $parent.
public
static isChildOf(string|UriInterface|Url $child, string|UriInterface|Url $parent) : bool
Relative URLs mean that multiple strings may not
Parameters
Return values
boolparseInternalRoute()
Parse an internal URL. Extract the CiviCRM route.
public
static parseInternalRoute(string $pageUrl[, string|null $cmsRootUrl = NULL ]) : array<string|int, mixed>
Parameters
- $pageUrl : string
-
Ex: 'https://example.com/cms/civicrm/foo?id=1'
- $cmsRootUrl : string|null = NULL
Tags
Return values
array<string|int, mixed> —Ex: ['path' => 'civicrm/foo', 'query' => 'id=1']
Similar to parse_url(), this returns a key-value array. Keys are: 'path', 'query', 'fragment', 'user', 'pass' Keys are only returned if they have values. Unused elements are omitted.
Currently, this does not support detecting schemes (such as frontend or backend).
parseUrl()
Parse url to a UriInterface.
public
static parseUrl(string $url) : UriInterface
Parameters
- $url : string
Return values
UriInterfacetoAbsolute()
Convert to an absolute URL (if relative).
public
static toAbsolute(string $value[, string|null $currentHostPort = NULL ]) : string
Parameters
- $value : string
- $currentHostPort : string|null = NULL
-
The value of HTTP_HOST. (NULL means "lookup HTTP_HOST")
Return values
string —Either the relative version of $value (if on the same HTTP_HOST), or else the absolute version.
toRelative()
Convert to a relative URL (if host/port matches).
public
static toRelative(string $value[, string|null $currentHostPort = NULL ]) : string
Parameters
- $value : string
- $currentHostPort : string|null = NULL
-
The value of HTTP_HOST. (NULL means "lookup HTTP_HOST")
Return values
string —Either the relative version of $value (if on the same HTTP_HOST), or else the absolute version.
unparseUrl()
Unparse url back to a string.
public
static unparseUrl(UriInterface $parsed) : string
Parameters
- $parsed : UriInterface