Documentation

Url extends Uri
in package

Represents an URL as specified in RFC 3986

Tags
link
https://tools.ietf.org/html/rfc3986
todo

Add query section parsing

copyright

CLOUDREXX CMS - CLOUDREXX AG

author

Michael Ritter drissg@gmail.com

version
1.0.0
subpackage

lib_net

Table of Contents

Constants

AUTHORITY_SECTION_REGEX  = '/^(?:([^@:]*)(?::([^@]*))?@)?(.*?)(?::([0-9]+))?$/'
AUTHORITY_SECTION_REGEX_INDEX_HOST  = 3
AUTHORITY_SECTION_REGEX_INDEX_PASSWORD  = 2
AUTHORITY_SECTION_REGEX_INDEX_PORT  = 4
AUTHORITY_SECTION_REGEX_INDEX_USERNAME  = 1
FRAGMENT_DELIMITER  = '#'
PASSWORD_DELIMITER  = ':'
PATH_DELIMITER_WITH_AUTHORITY  = '/'
PATH_DELIMITER_WITHOUT_AUTHORITY  = ':'
PORT_DELIMITER  = ':'
QUERY_DELIMITER  = '?'
SCHEME_DELIMITER_WITH_AUTHORITY  = '://'
SCHEME_DELIMITER_WITHOUT_AUTHORITY  = ':'
URI_REGEX  = '@^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?@'
URI_REGEX_INDEX_AUTHORITY  = 4
URI_REGEX_INDEX_FRAGMENT  = 9
URI_REGEX_INDEX_PATH  = 5
URI_REGEX_INDEX_QUERY  = 7
URI_REGEX_INDEX_SCHEME  = 2
USER_INFORMATION_DELIMITER  = '@'

Properties

$authority  : string
$fragment  : string
$host  : string
$localeCodes  : array<string|int, mixed>
List of locale codes ordered by translation fallback order per Cx instance
$nestingCount  : int
Counts the nesting level of __call()
$password  : string
$path  : array<string|int, mixed>
$pathDelimiter  : string
$port  : int
$query  : string
$scheme  : string
$stringRepresentationBlank  : bool
Whether blank string representations are valid
$stringRepresentationFields  : array<string|int, mixed>
List of fields that should be available in the string representation
$stringRepresentationFormat  : string
Sprintf format for the string representation
$username  : string
$validators  : array<string|int, mixed>
Initialize this array as follows: array( 'columName' => Zend_Validate )
$virtual  : bool
Defines if an entity is virtual and therefore not persistable.

Methods

__call()  : mixed
Route methods like getName(), getType(), getDirectory(), etc.
__construct()  : mixed
Creates a new Uri instance
__get()  : mixed
This is an ugly solution to allow $this->cx to be available in all entity classes Since the entity's constructor is not called when an entity is loaded from DB this cannot be assigned there.
__toString()  : string
Returns Uri as string
getAuthority()  : string
Re-assembles authority parts and returns the complete authority section
getComponentController()  : SystemComponent
Returns the component controller for this component
getFragment()  : string
Returns the current fragment section
getHost()  : string
Returns the current host
getKeyAsString()  : string
Returns this entity's key
getParam()  : string|null
Returns a value from the query section based on given key, null if not set
getParamArray()  : array<string|int, mixed>
Returns the parsed parts of the query section based on php.ini
getParsedQuery()  : array<string|int, mixed>
Returns the parsed parts of the query section based on php.ini
getPassword()  : string
Returns the current password
getPath()  : string
Returns the current path section
getPathDelimiter()  : string
Returns the current path delimiter
getPathParts()  : array<string|int, mixed>
Returns the current path section split by path delimiter
getPort()  : int
Returns the current port
getQuery()  : string
Returns the current query section
getScheme()  : string
Returns the current scheme
getTranslatedFieldValue()  : mixed
Returns the value of a translatable field using fallback mechanisms
getUsername()  : string
Returns the current username
hasAuthority()  : bool
Tells wheter this Uri has an authority section
hasFragment()  : bool
Tells wheter this Uri has a fragment section
hasParam()  : bool
Checks wheter a key is present in this URL's query section
hasPassword()  : bool
Tells wheter this Url has a password section
hasPort()  : bool
Tells wheter this Url has a port section
hasQuery()  : bool
Tells wheter this Uri has a query section
hasUserInformation()  : bool
Tells wheter this Url has a user information section
initializeValidators()  : mixed
Set $this->validators
isVirtual()  : bool
Returns the virtuality of the entity
removeAllParams()  : mixed
Sets an empty query section to this URL
setAuthority()  : mixed
Sets the current authority, forces authority to be present and splits it into parts
setFragment()  : mixed
Sets the current fragment
setHost()  : mixed
Sets the current host
setParam()  : mixed
Sets or unsets a key/value pair of the query section
setParams()  : mixed
Sets or unsets key/value pairs of the query section
setParsedQuery()  : mixed
Sets the parsed query
setPassword()  : mixed
Sets the current password
setPath()  : mixed
Sets the current path
setPathDelimiter()  : mixed
Sets the current path delimiter
setPort()  : mixed
Sets the current port
setQuery()  : mixed
Sets the current query
setScheme()  : mixed
Sets the current scheme
setUsername()  : mixed
Sets the current username
setVirtual()  : mixed
Set the virtuality of the entity
toString()  : string
Returns the string representation for this URI
validate()  : mixed
getFallbackLocaleCodes()  : array<string|int, mixed>
Returns a list of all locale codes ordered by fallback order
getStringRepresentationBlank()  : bool
Whether blank string representations are valid
getStringRepresentationFields()  : array<string|int, mixed>
Returns a list of fields available in the string representation
getStringRepresentationFormat()  : string
Returns the sprintf() format for the string representation

Constants

AUTHORITY_SECTION_REGEX

public string AUTHORITY_SECTION_REGEX = '/^(?:([^@:]*)(?::([^@]*))?@)?(.*?)(?::([0-9]+))?$/'

Regular expression to split authority section

AUTHORITY_SECTION_REGEX_INDEX_HOST

public int AUTHORITY_SECTION_REGEX_INDEX_HOST = 3

Index of the above REGEX for host part

AUTHORITY_SECTION_REGEX_INDEX_PASSWORD

public int AUTHORITY_SECTION_REGEX_INDEX_PASSWORD = 2

Index of the above REGEX for password part

AUTHORITY_SECTION_REGEX_INDEX_PORT

public int AUTHORITY_SECTION_REGEX_INDEX_PORT = 4

Index of the above REGEX for port part

AUTHORITY_SECTION_REGEX_INDEX_USERNAME

public int AUTHORITY_SECTION_REGEX_INDEX_USERNAME = 1

Index of the above REGEX for username part

FRAGMENT_DELIMITER

public string FRAGMENT_DELIMITER = '#'

Delimiter for fragment section

PASSWORD_DELIMITER

public string PASSWORD_DELIMITER = ':'

Delimiter to separate username and password

PATH_DELIMITER_WITH_AUTHORITY

public string PATH_DELIMITER_WITH_AUTHORITY = '/'

Delimiter for path parts if there's an authority section

PATH_DELIMITER_WITHOUT_AUTHORITY

public string PATH_DELIMITER_WITHOUT_AUTHORITY = ':'

Delimiter for path parts if there's no authority section

PORT_DELIMITER

public string PORT_DELIMITER = ':'

Delimiter for port section

QUERY_DELIMITER

public string QUERY_DELIMITER = '?'

Delimiter for query section

SCHEME_DELIMITER_WITH_AUTHORITY

public string SCHEME_DELIMITER_WITH_AUTHORITY = '://'

Delimiter for scheme if there's an authority section

SCHEME_DELIMITER_WITHOUT_AUTHORITY

public string SCHEME_DELIMITER_WITHOUT_AUTHORITY = ':'

Delimiter for scheme if there's no authority section

URI_REGEX

public string URI_REGEX = '@^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?@'

Regular expression to split URIs from https://tools.ietf.org/html/rfc3986#page-50

URI_REGEX_INDEX_AUTHORITY

public int URI_REGEX_INDEX_AUTHORITY = 4

Index of the above REGEX for authority part

URI_REGEX_INDEX_FRAGMENT

public int URI_REGEX_INDEX_FRAGMENT = 9

Index of the above REGEX for fragment part

URI_REGEX_INDEX_PATH

public int URI_REGEX_INDEX_PATH = 5

Index of the above REGEX for path part

URI_REGEX_INDEX_QUERY

public int URI_REGEX_INDEX_QUERY = 7

Index of the above REGEX for query part

URI_REGEX_INDEX_SCHEME

public int URI_REGEX_INDEX_SCHEME = 2

Index of the above REGEX for scheme part

USER_INFORMATION_DELIMITER

public string USER_INFORMATION_DELIMITER = '@'

Delimiter for user information

Properties

$authority

protected string $authority

Authority part

$fragment

protected string $fragment = ''

Fragment part

$localeCodes

List of locale codes ordered by translation fallback order per Cx instance

protected static array<string|int, mixed> $localeCodes = array()

Array in the form: array(<instanceId> => array(<localeCode>, ...))

Tags
see
getFallbackLocaleCodes()

$nestingCount

Counts the nesting level of __call()

protected static int $nestingCount = 0

$password

protected string $password

Password

$path

protected array<string|int, mixed> $path

Path parts

$pathDelimiter

protected string $pathDelimiter

Currently used delimitier to separate path sub-parts

$query

protected string $query = ''

Query part

$scheme

protected string $scheme

Scheme part

$stringRepresentationBlank

Whether blank string representations are valid

protected bool $stringRepresentationBlank = false

Whether blank string representations are valid

Tags
see
getStringRepresentationBlank()

$stringRepresentationFields

List of fields that should be available in the string representation

protected array<string|int, mixed> $stringRepresentationFields = array()

List of field names

Tags
see
getStringRepresentationFields()

$stringRepresentationFormat

Sprintf format for the string representation

protected string $stringRepresentationFormat = ''

Sprintf format string

Tags
see
getStringRepresentationFormat()

$username

protected string $username

Username

$validators

Initialize this array as follows: array( 'columName' => Zend_Validate )

protected array<string|int, mixed> $validators = array()

$virtual

Defines if an entity is virtual and therefore not persistable.

protected bool $virtual = false

Defaults to FALSE - not virtual.

Methods

__call()

Route methods like getName(), getType(), getDirectory(), etc.

public __call(string $methodName, array<string|int, mixed> $arguments) : mixed
Parameters
$methodName : string

Name of method to call

$arguments : array<string|int, mixed>

List of arguments for the method to call

Tags
throws
Exception

If __call() nesting level reaches 20

Attributes
#[ReturnTypeWillChange]
Return values
mixed

Return value of the method to call

__construct()

Creates a new Uri instance

public __construct(string $stringUri) : mixed
Parameters
$stringUri : string

URI as string

__get()

This is an ugly solution to allow $this->cx to be available in all entity classes Since the entity's constructor is not called when an entity is loaded from DB this cannot be assigned there.

public __get(mixed $name) : mixed
Parameters
$name : mixed
Attributes
#[ReturnTypeWillChange]

__toString()

Returns Uri as string

public __toString() : string
Return values
string

Uri as string

getAuthority()

Re-assembles authority parts and returns the complete authority section

public getAuthority() : string
Return values
string

Authority section

getFragment()

Returns the current fragment section

public getFragment() : string
Return values
string

Fragment section

getHost()

Returns the current host

public getHost() : string
Return values
string

Host

getKeyAsString()

Returns this entity's key

public final getKeyAsString([string $separator = '/' ]) : string

If this entity has a composite key, the fields are separated by $separator.

Parameters
$separator : string = '/'

(optional) Separator for composite key fields, default "/"

Return values
string

Entity key as string

getParam()

Returns a value from the query section based on given key, null if not set

public getParam(string $key) : string|null
Parameters
$key : string

Key to look for

Tags
todo

Naming isn't consistent with RFC's expressions

Return values
string|null

Value for the given key or null if key is not set

getParamArray()

Returns the parsed parts of the query section based on php.ini

public getParamArray() : array<string|int, mixed>

Use getParsedQuery() instead

Return values
array<string|int, mixed>

Key=>value style array

getParsedQuery()

Returns the parsed parts of the query section based on php.ini

public getParsedQuery() : array<string|int, mixed>
Return values
array<string|int, mixed>

Key=>value style array

getPassword()

Returns the current password

public getPassword() : string
Return values
string

Password

getPath()

Returns the current path section

public getPath() : string
Return values
string

Path section

getPathDelimiter()

Returns the current path delimiter

public getPathDelimiter() : string
Return values
string

Path delimiter

getPathParts()

Returns the current path section split by path delimiter

public getPathParts() : array<string|int, mixed>
Return values
array<string|int, mixed>

Path section

getPort()

Returns the current port

public getPort() : int
Return values
int

Port

getQuery()

Returns the current query section

public getQuery() : string
Return values
string

Query section

getScheme()

Returns the current scheme

public getScheme() : string
Return values
string

Scheme

getTranslatedFieldValue()

Returns the value of a translatable field using fallback mechanisms

public getTranslatedFieldValue(string $fieldName) : mixed

If the field is not translatable its value is returned anyway. Tries to return the value in the following locales (if non-empty):

  • Current locale
  • Default locale
  • All other locales
Parameters
$fieldName : string

Name of a translatable field

getUsername()

Returns the current username

public getUsername() : string
Return values
string

Username

hasAuthority()

Tells wheter this Uri has an authority section

public hasAuthority() : bool
Return values
bool

True if there's an authority section, false otherwise

hasFragment()

Tells wheter this Uri has a fragment section

public hasFragment() : bool
Return values
bool

True if there's a fragment section, false otherwise

hasParam()

Checks wheter a key is present in this URL's query section

public hasParam(string $key) : bool
Parameters
$key : string

Key to look for

Tags
todo

Naming isn't consistent with RFC's expressions

Return values
bool

True if key is present, false otherwise

hasPassword()

Tells wheter this Url has a password section

public hasPassword() : bool
Return values
bool

True if there's an password section, false otherwise

hasPort()

Tells wheter this Url has a port section

public hasPort() : bool
Return values
bool

True if there's an port section, false otherwise

hasQuery()

Tells wheter this Uri has a query section

public hasQuery() : bool
Return values
bool

True if there's a query section, false otherwise

hasUserInformation()

Tells wheter this Url has a user information section

public hasUserInformation() : bool
Return values
bool

True if there's an user information section, false otherwise

initializeValidators()

Set $this->validators

public initializeValidators() : mixed

Validators can be found in lib/FRAMEWORK/Validator.class.php These will be executed if validate() is called

isVirtual()

Returns the virtuality of the entity

public isVirtual() : bool
Return values
bool

TRUE if the entity is virtual, otherwise FALSE

removeAllParams()

Sets an empty query section to this URL

public removeAllParams() : mixed

Use setQuery('') instead

setAuthority()

Sets the current authority, forces authority to be present and splits it into parts

public setAuthority(string $authority) : mixed
Parameters
$authority : string

New authority

setFragment()

Sets the current fragment

public setFragment(string $fragment) : mixed
Parameters
$fragment : string

New fragment

setHost()

Sets the current host

public setHost(string $host) : mixed
Parameters
$host : string

New host

setParam()

Sets or unsets a key/value pair of the query section

public setParam(string $key, string|null $value) : mixed
Parameters
$key : string

Key to set/unset

$value : string|null

Value to set. If null, key will be unset

Tags
todo

Naming isn't consistent with RFC's expressions

setParams()

Sets or unsets key/value pairs of the query section

public setParams(array<string|int, mixed> $paramArray) : mixed
Parameters
$paramArray : array<string|int, mixed>

Key=>value style array

Tags
todo

Naming isn't consistent with RFC's expressions

see
setParam()

setParsedQuery()

Sets the parsed query

public setParsedQuery(array<string|int, mixed> $queryParts) : mixed
Parameters
$queryParts : array<string|int, mixed>

Key=>value style array

setPassword()

Sets the current password

public setPassword(string $password) : mixed
Parameters
$password : string

New password

setPath()

Sets the current path

public setPath(string $path) : mixed
Parameters
$path : string

New path

setPathDelimiter()

Sets the current path delimiter

public setPathDelimiter(string $pathDelimiter) : mixed
Parameters
$pathDelimiter : string

New path delimiter

setPort()

Sets the current port

public setPort(int $port) : mixed
Parameters
$port : int

New port

setQuery()

Sets the current query

public setQuery(string $query) : mixed
Parameters
$query : string

New query

setScheme()

Sets the current scheme

public setScheme(string $scheme) : mixed
Parameters
$scheme : string

New scheme

setUsername()

Sets the current username

public setUsername(string $username) : mixed
Parameters
$username : string

New username

setVirtual()

Set the virtuality of the entity

public setVirtual(bool $virtual) : mixed
Parameters
$virtual : bool

TRUE to set the entity as virtual or otherwise to FALSE

toString()

Returns the string representation for this URI

public toString() : string
Tags
see
__toString()
todo

implement a (descendant) method for relative URI/Ls

Return values
string

String representation for this URI

getFallbackLocaleCodes()

Returns a list of all locale codes ordered by fallback order

protected getFallbackLocaleCodes() : array<string|int, mixed>
  • First entry is the current locale
  • Second entry is the default locale (if different from current, it's omitted otherwise)
  • Then all other locales follow (in no particular order)
Tags
todo

Order the array by the fallback order (same as in ContentManager)

Return values
array<string|int, mixed>

List of locale codes

getStringRepresentationBlank()

Whether blank string representations are valid

protected getStringRepresentationBlank() : bool
Return values
bool

Whether blank string representations are valid

getStringRepresentationFields()

Returns a list of fields available in the string representation

protected getStringRepresentationFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

List of field names

getStringRepresentationFormat()

Returns the sprintf() format for the string representation

protected getStringRepresentationFormat() : string
Return values
string

sprintf() format string


        
On this page

Search results