PHP Класс Prado\Web\TUrlMapping

The TUrlMapping module allows PRADO to construct and recognize URLs based on specific patterns. TUrlMapping consists of a list of URL patterns which are used to match against the currently requested URL. The first matching pattern will then be used to decompose the URL into request parameters (accessible through $this->Request['paramname']). The patterns can also be used to construct customized URLs. In this case, the parameters in an applied pattern will be replaced with the corresponding GET variable values. Since it is derived from {@link TUrlManager}, it should be configured globally in the application configuration like the following, In the above, each <url> element specifies a URL pattern represented as a {@link TUrlMappingPattern} internally. You may create your own pattern classes by extending {@link TUrlMappingPattern} and specifying the <class> attribute in the element. The patterns can be also be specified in an external file using the {@link setConfigFile ConfigFile} property. The URL mapping are evaluated in order, only the first mapping that matches the URL will be used. Cascaded mapping can be achieved by placing the URL mappings in particular order. For example, placing the most specific mappings first. Only the PATH_INFO part of the URL is used to match the available patterns. The matching is strict in the sense that the whole pattern must match the whole PATH_INFO of the URL. From PRADO v3.1.1, TUrlMapping also provides support for constructing URLs according to the specified pattern. You may enable this functionality by setting {@link setEnableCustomUrl EnableCustomUrl} to true. When you call THttpRequest::constructUrl() (or via TPageService::constructUrl()), TUrlMapping will examine the available URL mapping patterns using their {@link TUrlMappingPattern::getServiceParameter ServiceParameter} and {@link TUrlMappingPattern::getPattern Pattern} properties. A pattern is applied if its {@link TUrlMappingPattern::getServiceParameter ServiceParameter} matches the service parameter passed to constructUrl() and every parameter in the {@link getPattern Pattern} is found in the GET variables.
С версии: 3.0.5
Наследование: extends TUrlManager
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$_constructRules rules for constructing URLs
$_patterns list of patterns.

Открытые методы

Метод Описание
constructUrl ( $serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems ) : string Constructs a URL that can be recognized by PRADO.
getConfigFile ( ) : string
getDefaultMappingClass ( ) : string
getEnableCustomUrl ( ) : boolean Returns a value indicating whether to enable custom constructUrl.
getMatchingPattern ( ) : TUrlMappingPattern
getUrlPrefix ( ) : string
init ( $config ) Initializes this module.
parseUrl ( ) : array Parses the request URL and returns an array of input parameters.
setConfigFile ( $value )
setDefaultMappingClass ( $value ) Sets the default class of URL mapping patterns.
setEnableCustomUrl ( $value ) Sets a value indicating whether to enable custom constructUrl.
setUrlPrefix ( $value )

Защищенные методы

Метод Описание
loadConfigFile ( ) Initialize the module from configuration file.
loadUrlMappings ( $config ) Load and configure each url mapping pattern.

Приватные методы

Метод Описание
buildUrlMapping ( $class, $properties, $url )

Описание методов

constructUrl() публичный Метод

This method provides the actual implementation used by {@link THttpRequest::constructUrl}. Override this method if you want to provide your own way of URL formatting. If you do so, you may also need to override {@link parseUrl} so that the URL can be properly parsed. The URL is constructed as the following format: entryscript.php?serviceID=serviceParameter&get1=value1&... If {@link THttpRequest::setUrlFormat THttpRequest.UrlFormat} is 'Path', the following format is used instead: entryscript.php/serviceID/serviceParameter/get1,value1/get2,value2... If {@link THttpRequest::setUrlFormat THttpRequest.UrlFormat} is 'HiddenPath', the following format is used instead: serviceID/serviceParameter/get1,value1/get2,value2...
См. также: parseUrl
С версии: 3.1.1
public constructUrl ( $serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems ) : string
Результат string URL

getConfigFile() публичный Метод

public getConfigFile ( ) : string
Результат string external configuration file. Defaults to null.

getDefaultMappingClass() публичный Метод

С версии: 3.1.1
public getDefaultMappingClass ( ) : string
Результат string the default class of URL mapping patterns. Defaults to TUrlMappingPattern.

getEnableCustomUrl() публичный Метод

If true, constructUrl() will make use of the URL mapping rules to construct valid URLs.
С версии: 3.1.1
public getEnableCustomUrl ( ) : boolean
Результат boolean whether to enable custom constructUrl. Defaults to false.

getMatchingPattern() публичный Метод

public getMatchingPattern ( ) : TUrlMappingPattern
Результат TUrlMappingPattern the matched pattern, null if not found.

getUrlPrefix() публичный Метод

С версии: 3.1.1
public getUrlPrefix ( ) : string
Результат string the part that will be prefixed to the constructed URLs. Defaults to the requested script path (e.g. /path/to/index.php for a URL http://hostname/path/to/index.php)

init() публичный Метод

This method is required by the IModule interface.
public init ( $config )

loadConfigFile() защищенный Метод

Initialize the module from configuration file.
protected loadConfigFile ( )

loadUrlMappings() защищенный Метод

Load and configure each url mapping pattern.
protected loadUrlMappings ( $config )

parseUrl() публичный Метод

This method overrides the parent implementation. The input parameters do not include GET and POST variables. This method uses the request URL path to find the first matching pattern. If found the matched pattern parameters are used to return as the input parameters.
public parseUrl ( ) : array
Результат array list of input parameters

setConfigFile() публичный Метод

public setConfigFile ( $value )

setDefaultMappingClass() публичный Метод

When a URL matching pattern does not specify "class" attribute, it will default to the class specified by this property. You may use either a class name or a namespace format of class (if the class needs to be included first.)
С версии: 3.1.1
public setDefaultMappingClass ( $value )

setEnableCustomUrl() публичный Метод

If true, constructUrl() will make use of the URL mapping rules to construct valid URLs.
С версии: 3.1.1
public setEnableCustomUrl ( $value )

setUrlPrefix() публичный Метод

См. также: getUrlPrefix
С версии: 3.1.1
public setUrlPrefix ( $value )

Описание свойств

$_constructRules защищенное свойство

rules for constructing URLs
protected $_constructRules

$_patterns защищенное свойство

list of patterns.
protected $_patterns