ILIAS
release_5-3 Revision v5.3.23-19-g915713cf615
|
Value object representing a URI. More...
Public Member Functions | |
__construct ( $scheme, $host, $port=null, $path='/', $query='', $fragment='', $user='', $password='') | |
Create new Uri. More... | |
getScheme () | |
Retrieve the scheme component of the URI. More... | |
withScheme ($scheme) | |
Return an instance with the specified scheme. More... | |
getAuthority () | |
Retrieve the authority component of the URI. More... | |
getUserInfo () | |
Retrieve the user information component of the URI. More... | |
withUserInfo ($user, $password=null) | |
Return an instance with the specified user information. More... | |
getHost () | |
Retrieve the host component of the URI. More... | |
withHost ($host) | |
Return an instance with the specified host. More... | |
getPort () | |
Retrieve the port component of the URI. More... | |
withPort ($port) | |
Return an instance with the specified port. More... | |
getPath () | |
Retrieve the path component of the URI. More... | |
withPath ($path) | |
Return an instance with the specified path. More... | |
getBasePath () | |
Retrieve the base path segment of the URI. More... | |
withBasePath ($basePath) | |
Set base path. More... | |
getQuery () | |
Retrieve the query string of the URI. More... | |
withQuery ($query) | |
Return an instance with the specified query string. More... | |
getFragment () | |
Retrieve the fragment component of the URI. More... | |
withFragment ($fragment) | |
Return an instance with the specified URI fragment. More... | |
__toString () | |
Return the string representation as a URI reference. More... | |
getBaseUrl () | |
Return the fully qualified base URL. More... | |
Static Public Member Functions | |
static | createFromString ($uri) |
Create new Uri from string. More... | |
static | createFromEnvironment (Environment $env) |
Create new Uri from environment. More... | |
Protected Member Functions | |
filterScheme ($scheme) | |
Filter Uri scheme. More... | |
filterUserInfo ($query) | |
Filters the user info string. More... | |
hasStandardPort () | |
Does this Uri use a standard port? More... | |
filterPort ($port) | |
Filter Uri port. More... | |
filterPath ($path) | |
Filter Uri path. More... | |
filterQuery ($query) | |
Filters the query string or fragment of a URI. More... | |
Protected Attributes | |
$scheme = '' | |
$user = '' | |
$password = '' | |
$host = '' | |
$port | |
$basePath = '' | |
$path = '' | |
$query = '' | |
$fragment = '' | |
Value object representing a URI.
This interface is meant to represent URIs according to RFC 3986 and to provide methods for most common operations. Additional functionality for working with URIs can be provided on top of the interface or externally. Its primary use is for HTTP requests, but may also be used in other contexts.
Instances of this interface are considered immutable; all methods that might change state MUST be implemented such that they retain the internal state of the current instance and return an instance that contains the changed state.
Typically the Host header will be also be present in the request message. For server-side requests, the scheme will typically be discoverable in the server parameters.
Slim\Http\Uri::__construct | ( | $scheme, | |
$host, | |||
$port = null , |
|||
$path = '/' , |
|||
$query = '' , |
|||
$fragment = '' , |
|||
$user = '' , |
|||
$password = '' |
|||
) |
Create new Uri.
string | $scheme | Uri scheme. |
string | $host | Uri host. |
int | $port | Uri port number. |
string | $path | Uri path. |
string | $query | Uri query string. |
string | $fragment | Uri fragment. |
string | $user | Uri user. |
string | $password | Uri password. |
Definition at line 112 of file Uri.php.
References Slim\Http\Uri\$fragment, Slim\Http\Uri\$host, Slim\Http\Uri\$password, Slim\Http\Uri\$path, Slim\Http\Uri\$port, Slim\Http\Uri\$query, Slim\Http\Uri\$scheme, Slim\Http\Uri\$user, Slim\Http\Uri\filterPath(), Slim\Http\Uri\filterPort(), Slim\Http\Uri\filterQuery(), Slim\Http\Uri\filterScheme(), and user().
Slim\Http\Uri::__toString | ( | ) |
Return the string representation as a URI reference.
Depending on which components of the URI are present, the resulting string is either a full URI or relative reference according to RFC 3986, Section 4.1. The method concatenates the various components of the URI, using the appropriate delimiters:
Implements Psr\Http\Message\UriInterface.
Definition at line 806 of file Uri.php.
References $authority, Slim\Http\Uri\$basePath, Slim\Http\Uri\$fragment, Slim\Http\Uri\$path, Slim\Http\Uri\$query, Slim\Http\Uri\$scheme, Slim\Http\Uri\getAuthority(), Slim\Http\Uri\getBasePath(), Slim\Http\Uri\getFragment(), Slim\Http\Uri\getPath(), Slim\Http\Uri\getQuery(), and Slim\Http\Uri\getScheme().
|
static |
Create new Uri from environment.
Environment | $env |
Definition at line 166 of file Uri.php.
References Slim\Http\Uri\$basePath, Slim\Http\Uri\$fragment, Slim\Http\Uri\$host, Slim\Http\Uri\$password, Slim\Http\Uri\$port, Slim\Http\Uri\$scheme, Slim\Collection\get(), and Slim\Collection\has().
Referenced by Slim\Http\Request\createFromEnvironment().
|
static |
Create new Uri from string.
string | $uri | Complete Uri string (i.e., https://user:pass@host:443/path?query). |
Definition at line 140 of file Uri.php.
References Slim\Http\Uri\$fragment, Slim\Http\Uri\$host, $pass, Slim\Http\Uri\$path, Slim\Http\Uri\$port, Slim\Http\Uri\$query, Slim\Http\Uri\$scheme, and Slim\Http\Uri\$user.
|
protected |
Filter Uri path.
This method percent-encodes all reserved characters in the provided path string. This method will NOT double-encode characters that are already percent-encoded.
string | $path | The raw uri path. |
Definition at line 644 of file Uri.php.
References Slim\Http\Uri\$path.
Referenced by Slim\Http\Uri\__construct(), Slim\Http\Uri\withBasePath(), and Slim\Http\Uri\withPath().
|
protected |
Filter Uri port.
null | int | $port | The Uri port number. |
InvalidArgumentException | If the port is invalid. |
Definition at line 510 of file Uri.php.
References Slim\Http\Uri\$port.
Referenced by Slim\Http\Uri\__construct(), and Slim\Http\Uri\withPort().
|
protected |
Filters the query string or fragment of a URI.
string | $query | The raw uri query string. |
Definition at line 717 of file Uri.php.
References Slim\Http\Uri\$query.
Referenced by Slim\Http\Uri\__construct(), Slim\Http\Uri\withFragment(), and Slim\Http\Uri\withQuery().
|
protected |
Filter Uri scheme.
string | $scheme | Raw Uri scheme. |
InvalidArgumentException | If the Uri scheme is not a string. |
InvalidArgumentException | If Uri scheme is not "", "https", or "http". |
Definition at line 295 of file Uri.php.
References Slim\Http\Uri\$scheme, and $valid.
Referenced by Slim\Http\Uri\__construct(), and Slim\Http\Uri\withScheme().
|
protected |
Filters the user info string.
string | $query | The raw uri query string. |
Definition at line 399 of file Uri.php.
References Slim\Http\Uri\$query.
Referenced by Slim\Http\Uri\withUserInfo().
Slim\Http\Uri::getAuthority | ( | ) |
Retrieve the authority component of the URI.
If no authority information is present, this method MUST return an empty string.
The authority syntax of the URI is:
[user-info@]host[:port]
If the port component is not set or is the standard port for the current scheme, it SHOULD NOT be included.
Implements Psr\Http\Message\UriInterface.
Definition at line 337 of file Uri.php.
References Slim\Http\Uri\$host, Slim\Http\Uri\$port, Slim\Http\Uri\getHost(), Slim\Http\Uri\getPort(), and Slim\Http\Uri\getUserInfo().
Referenced by Slim\Http\Uri\__toString(), and Slim\Http\Uri\getBaseUrl().
Slim\Http\Uri::getBasePath | ( | ) |
Retrieve the base path segment of the URI.
Note: This method is not part of the PSR-7 standard.
This method MUST return a string; if no path is present it MUST return an empty string.
Definition at line 602 of file Uri.php.
References Slim\Http\Uri\$basePath.
Referenced by Slim\Http\Uri\__toString(), and Slim\Http\Uri\getBaseUrl().
Slim\Http\Uri::getBaseUrl | ( | ) |
Return the fully qualified base URL.
Note that this method never includes a trailing /
This method is not part of PSR-7.
Definition at line 833 of file Uri.php.
References $authority, Slim\Http\Uri\$basePath, Slim\Http\Uri\$scheme, Slim\Http\Uri\getAuthority(), Slim\Http\Uri\getBasePath(), and Slim\Http\Uri\getScheme().
Slim\Http\Uri::getFragment | ( | ) |
Retrieve the fragment component of the URI.
If no fragment is present, this method MUST return an empty string.
The leading "#" character is not part of the fragment and MUST NOT be added.
The value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.5.
Implements Psr\Http\Message\UriInterface.
Definition at line 748 of file Uri.php.
References Slim\Http\Uri\$fragment.
Referenced by Slim\Http\Uri\__toString().
Slim\Http\Uri::getHost | ( | ) |
Retrieve the host component of the URI.
If no host is present, this method MUST return an empty string.
The value returned MUST be normalized to lowercase, per RFC 3986 Section 3.2.2.
Implements Psr\Http\Message\UriInterface.
Definition at line 421 of file Uri.php.
References Slim\Http\Uri\$host.
Referenced by Slim\Http\Uri\getAuthority().
Slim\Http\Uri::getPath | ( | ) |
Retrieve the path component of the URI.
The path can either be empty or absolute (starting with a slash) or rootless (not starting with a slash). Implementations MUST support all three syntaxes.
Normally, the empty path "" and absolute path "/" are considered equal as defined in RFC 7230 Section 2.7.3. But this method MUST NOT automatically do this normalization because in contexts with a trimmed base path, e.g. the front controller, this difference becomes significant. It's the task of the user to handle both "" and "/".
The value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.3.
As an example, if the value should include a slash ("/") not intended as delimiter between path segments, that value MUST be passed in encoded form (e.g., "%2F") to the instance.
Implements Psr\Http\Message\UriInterface.
Definition at line 548 of file Uri.php.
References Slim\Http\Uri\$path.
Referenced by Slim\Http\Uri\__toString().
Slim\Http\Uri::getPort | ( | ) |
Retrieve the port component of the URI.
If a port is present, and it is non-standard for the current scheme, this method MUST return it as an integer. If the port is the standard port used with the current scheme, this method SHOULD return null.
If no port is present, and no scheme is present, this method MUST return a null value.
If no port is present, but a scheme is present, this method MAY return the standard port for that scheme, but SHOULD return null.
Implements Psr\Http\Message\UriInterface.
Definition at line 461 of file Uri.php.
References Slim\Http\Uri\hasStandardPort().
Referenced by Slim\Http\Uri\getAuthority().
Slim\Http\Uri::getQuery | ( | ) |
Retrieve the query string of the URI.
If no query string is present, this method MUST return an empty string.
The leading "?" character is not part of the query and MUST NOT be added.
The value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.4.
As an example, if a value in a key/value pair of the query string should include an ampersand ("&") not intended as a delimiter between values, that value MUST be passed in encoded form (e.g., "%26") to the instance.
Implements Psr\Http\Message\UriInterface.
Definition at line 679 of file Uri.php.
References Slim\Http\Uri\$query.
Referenced by Slim\Http\Uri\__toString().
Slim\Http\Uri::getScheme | ( | ) |
Retrieve the scheme component of the URI.
If no scheme is present, this method MUST return an empty string.
The value returned MUST be normalized to lowercase, per RFC 3986 Section 3.1.
The trailing ":" character is not part of the scheme and MUST NOT be added.
Implements Psr\Http\Message\UriInterface.
Definition at line 257 of file Uri.php.
References Slim\Http\Uri\$scheme.
Referenced by Slim\Http\Uri\__toString(), and Slim\Http\Uri\getBaseUrl().
Slim\Http\Uri::getUserInfo | ( | ) |
Retrieve the user information component of the URI.
If no user information is present, this method MUST return an empty string.
If a user is present in the URI, this will return that value; additionally, if the password is also present, it will be appended to the user value, with a colon (":") separating the values.
The trailing "@" character is not part of the user information and MUST NOT be added.
Implements Psr\Http\Message\UriInterface.
Definition at line 361 of file Uri.php.
References user().
Referenced by Slim\Http\Uri\getAuthority().
|
protected |
Does this Uri use a standard port?
Definition at line 497 of file Uri.php.
Referenced by Slim\Http\Uri\getPort().
Slim\Http\Uri::withBasePath | ( | $basePath | ) |
Set base path.
Note: This method is not part of the PSR-7 standard.
string | $basePath |
Definition at line 615 of file Uri.php.
References Slim\Http\Uri\$basePath, and Slim\Http\Uri\filterPath().
Slim\Http\Uri::withFragment | ( | $fragment | ) |
Return an instance with the specified URI fragment.
This method MUST retain the state of the current instance, and return an instance that contains the specified URI fragment.
Users can provide both encoded and decoded fragment characters. Implementations ensure the correct encoding as outlined in getFragment().
An empty fragment value is equivalent to removing the fragment.
string | $fragment | The fragment to use with the new instance. |
Implements Psr\Http\Message\UriInterface.
Definition at line 767 of file Uri.php.
References Slim\Http\Uri\$fragment, and Slim\Http\Uri\filterQuery().
Slim\Http\Uri::withHost | ( | $host | ) |
Return an instance with the specified host.
This method MUST retain the state of the current instance, and return an instance that contains the specified host.
An empty host value is equivalent to removing the host.
string | $host | The hostname to use with the new instance. |
Implements Psr\Http\Message\UriInterface.
Definition at line 438 of file Uri.php.
References Slim\Http\Uri\$host.
Slim\Http\Uri::withPath | ( | $path | ) |
Return an instance with the specified path.
This method MUST retain the state of the current instance, and return an instance that contains the specified path.
The path can either be empty or absolute (starting with a slash) or rootless (not starting with a slash). Implementations MUST support all three syntaxes.
If the path is intended to be domain-relative rather than path relative then it must begin with a slash ("/"). Paths not starting with a slash ("/") are assumed to be relative to some base path known to the application or consumer.
Users can provide both encoded and decoded path characters. Implementations ensure the correct encoding as outlined in getPath().
string | $path | The path to use with the new instance. |
Implements Psr\Http\Message\UriInterface.
Definition at line 575 of file Uri.php.
References Slim\Http\Uri\$path, and Slim\Http\Uri\filterPath().
Slim\Http\Uri::withPort | ( | $port | ) |
Return an instance with the specified port.
This method MUST retain the state of the current instance, and return an instance that contains the specified port.
Implementations MUST raise an exception for ports outside the established TCP and UDP port ranges.
A null value provided for the port is equivalent to removing the port information.
null | int | $port | The port to use with the new instance; a null value removes the port information. |
Implements Psr\Http\Message\UriInterface.
Definition at line 483 of file Uri.php.
References Slim\Http\Uri\$port, and Slim\Http\Uri\filterPort().
Slim\Http\Uri::withQuery | ( | $query | ) |
Return an instance with the specified query string.
This method MUST retain the state of the current instance, and return an instance that contains the specified query string.
Users can provide both encoded and decoded query characters. Implementations ensure the correct encoding as outlined in getQuery().
An empty query string value is equivalent to removing the query string.
string | $query | The query string to use with the new instance. |
Implements Psr\Http\Message\UriInterface.
Definition at line 699 of file Uri.php.
References Slim\Http\Uri\$query, and Slim\Http\Uri\filterQuery().
Slim\Http\Uri::withScheme | ( | $scheme | ) |
Return an instance with the specified scheme.
This method MUST retain the state of the current instance, and return an instance that contains the specified scheme.
Implementations MUST support the schemes "http" and "https" case insensitively, and MAY accommodate other schemes if required.
An empty scheme is equivalent to removing the scheme.
string | $scheme | The scheme to use with the new instance. |
Implements Psr\Http\Message\UriInterface.
Definition at line 277 of file Uri.php.
References Slim\Http\Uri\$scheme, and Slim\Http\Uri\filterScheme().
Slim\Http\Uri::withUserInfo | ( | $user, | |
$password = null |
|||
) |
Return an instance with the specified user information.
This method MUST retain the state of the current instance, and return an instance that contains the specified user information.
Password is optional, but the user information MUST include the user; an empty string for the user is equivalent to removing user information.
string | $user | The user name to use for authority. |
null | string | $password | The password associated with $user. |
Implements Psr\Http\Message\UriInterface.
Definition at line 380 of file Uri.php.
References Slim\Http\Uri\$password, Slim\Http\Uri\$user, and Slim\Http\Uri\filterUserInfo().
|
protected |
Definition at line 77 of file Uri.php.
Referenced by Slim\Http\Uri\__toString(), Slim\Http\Uri\createFromEnvironment(), Slim\Http\Uri\getBasePath(), Slim\Http\Uri\getBaseUrl(), and Slim\Http\Uri\withBasePath().
|
protected |
Definition at line 98 of file Uri.php.
Referenced by Slim\Http\Uri\__construct(), Slim\Http\Uri\__toString(), Slim\Http\Uri\createFromEnvironment(), Slim\Http\Uri\createFromString(), Slim\Http\Uri\getFragment(), and Slim\Http\Uri\withFragment().
|
protected |
Definition at line 63 of file Uri.php.
Referenced by Slim\Http\Uri\__construct(), Slim\Http\Uri\createFromEnvironment(), Slim\Http\Uri\createFromString(), Slim\Http\Uri\getAuthority(), Slim\Http\Uri\getHost(), and Slim\Http\Uri\withHost().
|
protected |
Definition at line 56 of file Uri.php.
Referenced by Slim\Http\Uri\__construct(), Slim\Http\Uri\createFromEnvironment(), and Slim\Http\Uri\withUserInfo().
|
protected |
Definition at line 84 of file Uri.php.
Referenced by Slim\Http\Uri\__construct(), Slim\Http\Uri\__toString(), Slim\Http\Uri\createFromString(), Slim\Http\Uri\filterPath(), Slim\Http\Uri\getPath(), and Slim\Http\Uri\withPath().
|
protected |
Definition at line 70 of file Uri.php.
Referenced by Slim\Http\Uri\__construct(), Slim\Http\Uri\createFromEnvironment(), Slim\Http\Uri\createFromString(), Slim\Http\Uri\filterPort(), Slim\Http\Uri\getAuthority(), and Slim\Http\Uri\withPort().
|
protected |
Definition at line 91 of file Uri.php.
Referenced by Slim\Http\Uri\__construct(), Slim\Http\Uri\__toString(), Slim\Http\Uri\createFromString(), Slim\Http\Uri\filterQuery(), Slim\Http\Uri\filterUserInfo(), Slim\Http\Uri\getQuery(), and Slim\Http\Uri\withQuery().
|
protected |
Definition at line 42 of file Uri.php.
Referenced by Slim\Http\Uri\__construct(), Slim\Http\Uri\__toString(), Slim\Http\Uri\createFromEnvironment(), Slim\Http\Uri\createFromString(), Slim\Http\Uri\filterScheme(), Slim\Http\Uri\getBaseUrl(), Slim\Http\Uri\getScheme(), and Slim\Http\Uri\withScheme().
|
protected |
Definition at line 49 of file Uri.php.
Referenced by Slim\Http\Uri\__construct(), Slim\Http\Uri\createFromString(), and Slim\Http\Uri\withUserInfo().