PHP 클래스 Prado\Web\TUrlMappingPattern

TUrlMappingPattern represents a pattern used to parse and construct URLs. If the currently requested URL matches the pattern, it will alter the THttpRequest parameters. If a constructUrl() call matches the pattern parameters, the pattern will generate a valid URL. In both case, only the PATH_INFO part of a URL is parsed/constructed using the pattern. To specify the pattern, set the {@link setPattern Pattern} property. {@link setPattern Pattern} takes a string expression with parameter names enclosed between a left brace '{' and a right brace '}'. The patterns for each parameter can be set using {@link getParameters Parameters} attribute collection. For example In the above example, the pattern contains 3 parameters named "year", "month" and "day". The pattern for these parameters are, respectively, "\d{4}" (4 digits), "\d{2}" (2 digits) and "\d+" (1 or more digits). Essentially, the Parameters attribute name and values are used as substrings in replacing the placeholders in the Pattern string to form a complete regular expression string. For more complicated patterns, one may specify the pattern using a regular expression by {@link setRegularExpression RegularExpression}. For example, the above pattern is equivalent to the following regular expression-based pattern: #^articles/(?P\d{4})/(?P\d{2})\/(?P\d+)$#u The above regular expression used the "named group" feature available in PHP. If you intended to use the RegularExpression property or regular expressions in CDATA sections, notice that you need to escape the slash, if you are using the slash as regular expressions delimiter. Thus, only an url that matches the pattern will be valid. For example, a URL http://example.com/index.php/articles/2006/07/21 will match the above pattern, while http://example.com/index.php/articles/2006/07/hello will not since the "day" parameter pattern is not satisfied. The parameter values are available through the THttpRequest instance (e.g. $this->Request['year']). The {@link setServiceParameter ServiceParameter} and {@link setServiceID ServiceID} (the default ID is 'page') set the service parameter and service id respectively. Since 3.1.4 you can also use simplyfied wildcard patterns to match multiple ServiceParameters with a single rule. The pattern must contain the placeholder {*} for the ServiceParameter. For example This rule will match an URL like http://example.com/index.php/admin/edituser and resolve it to the page Application.pages.admin.edituser. The wildcard matching is non-recursive. That means you have to add a rule for every subdirectory you want to access pages in: It is still possible to define an explicit rule for a page in the wildcard path. This rule has to preceed the wildcard rule. You can also use parameters with wildcard patterns. The parameters are then available with every matching page: To enable automatic parameter encoding in a path format from wildcard patterns you can set {@setUrlFormat UrlFormat} to 'Path': This will create and parse URLs of the form .../index.php/admin/listuser/param1/value1/param2/value2. Use {@setUrlParamSeparator} to define another separator character between parameter name and value. Parameter/value pairs are always separated by a '/'. .../index.php/admin/listuser/param1-value1/param2-value2. Since 3.2.2 you can also add a list of "constants" parameters that can be used just like the original "parameters" parameters, except that the supplied value will be treated as a simple string constant instead of a regular expression. For example These rules, when matched by the actual request, will make the application see a "lisstype" parameter present (even through not supplied in the request) and equal to "detailed" or "summarized", depending on the friendly url matched. The constants is practically a table-based validation and translation of specified, fixed-set parameter values.
부터: 3.0.5
상속: extends Prado\TComponent
파일 보기 프로젝트 열기: pradosoft/prado

보호된 프로퍼티들

프로퍼티 타입 설명
$_constants of constant parameters.

공개 메소드들

메소드 설명
__construct ( TUrlManager $manager ) Constructor.
constructUrl ( $getItems, $encodeAmpersand, $encodeGetItems ) : string Constructs a URL using this pattern.
getCaseSensitive ( ) : boolean
getConstants ( ) : TAttributeCollection
getEnableCustomUrl ( ) : boolean Returns a value indicating whether to use this pattern to construct URL.
getIsWildCardPattern ( ) : boolean
getManager ( ) : TUrlManager
getParameters ( ) : TAttributeCollection
getPattern ( ) : string
getPatternMatches ( $request ) : array Uses URL pattern (or full regular expression if available) to match the given url path.
getRegularExpression ( ) : string
getSecureConnection ( ) : TUrlMappingPatternSecureConnection
getServiceID ( ) : string
getServiceParameter ( ) : string
getUrlFormat ( ) : THttpRequestUrlFormat
getUrlParamSeparator ( ) : string
init ( $config ) Initializes the pattern.
setCaseSensitive ( $value )
setEnableCustomUrl ( $value ) Sets a value indicating whether to enable custom constructUrl using this pattern
setParameters ( $value )
setPattern ( $value )
setRegularExpression ( $value )
setSecureConnection ( $value )
setServiceID ( $value )
setServiceParameter ( $value )
setUrlFormat ( $value ) Sets the format of URLs constructed and interpreted by this pattern.
setUrlParamSeparator ( $value )
supportCustomUrl ( $getItems ) : boolean

보호된 메소드들

메소드 설명
applySecureConnectionPrefix ( string $url ) : string Apply behavior of {@link SecureConnection} property by conditionaly prefixing URL with {@link THttpRequest::getBaseUrl()}
getParameterizedPattern ( ) : string Substitute the parameter key value pairs as named groupings in the regular expression matching pattern.

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( TUrlManager $manager )
$manager TUrlManager

applySecureConnectionPrefix() 보호된 메소드

Apply behavior of {@link SecureConnection} property by conditionaly prefixing URL with {@link THttpRequest::getBaseUrl()}
부터: 3.2
protected applySecureConnectionPrefix ( string $url ) : string
$url string
리턴 string

constructUrl() 공개 메소드

Constructs a URL using this pattern.
부터: 3.1.1
public constructUrl ( $getItems, $encodeAmpersand, $encodeGetItems ) : string
리턴 string the constructed URL

getCaseSensitive() 공개 메소드

public getCaseSensitive ( ) : boolean
리턴 boolean whether the {@link getPattern Pattern} should be treated as case sensititve. Defaults to true.

getConstants() 공개 메소드

부터: 3.2.2
public getConstants ( ) : TAttributeCollection
리턴 Prado\Collections\TAttributeCollection constanst parameter key value pairs.

getEnableCustomUrl() 공개 메소드

Returns a value indicating whether to use this pattern to construct URL.
부터: 3.1.1
public getEnableCustomUrl ( ) : boolean
리턴 boolean whether to enable custom constructUrl. Defaults to true.

getIsWildCardPattern() 공개 메소드

부터: 3.1.4
public getIsWildCardPattern ( ) : boolean
리턴 boolean whether this pattern is a wildcard pattern

getManager() 공개 메소드

public getManager ( ) : TUrlManager
리턴 TUrlManager the URL manager instance

getParameterizedPattern() 보호된 메소드

Substitute the parameter key value pairs as named groupings in the regular expression matching pattern.
protected getParameterizedPattern ( ) : string
리턴 string regular expression pattern with parameter subsitution

getParameters() 공개 메소드

public getParameters ( ) : TAttributeCollection
리턴 Prado\Collections\TAttributeCollection parameter key value pairs.

getPattern() 공개 메소드

public getPattern ( ) : string
리턴 string url pattern to match. Defaults to ''.

getPatternMatches() 공개 메소드

Uses URL pattern (or full regular expression if available) to match the given url path.
public getPatternMatches ( $request ) : array
리턴 array matched parameters, empty if no matches.

getRegularExpression() 공개 메소드

public getRegularExpression ( ) : string
리턴 string full regular expression mapping pattern

getSecureConnection() 공개 메소드

부터: 3.2
public getSecureConnection ( ) : TUrlMappingPatternSecureConnection
리턴 TUrlMappingPatternSecureConnection the SecureConnection behavior. Defaults to {@link TUrlMappingPatternSecureConnection::Automatic Automatic}

getServiceID() 공개 메소드

public getServiceID ( ) : string
리턴 string service id.

getServiceParameter() 공개 메소드

public getServiceParameter ( ) : string
리턴 string service parameter, such as page class name.

getUrlFormat() 공개 메소드

public getUrlFormat ( ) : THttpRequestUrlFormat
리턴 THttpRequestUrlFormat the format of URLs. Defaults to THttpRequestUrlFormat::Get.

getUrlParamSeparator() 공개 메소드

public getUrlParamSeparator ( ) : string
리턴 string separator used to separate GET variable name and value when URL format is Path. Defaults to slash '/'.

init() 공개 메소드

Initializes the pattern.
public init ( $config )

setCaseSensitive() 공개 메소드

public setCaseSensitive ( $value )

setEnableCustomUrl() 공개 메소드

Sets a value indicating whether to enable custom constructUrl using this pattern
public setEnableCustomUrl ( $value )

setParameters() 공개 메소드

public setParameters ( $value )

setPattern() 공개 메소드

public setPattern ( $value )

setRegularExpression() 공개 메소드

public setRegularExpression ( $value )

setSecureConnection() 공개 메소드

부터: 3.2
public setSecureConnection ( $value )

setServiceID() 공개 메소드

public setServiceID ( $value )

setServiceParameter() 공개 메소드

public setServiceParameter ( $value )

setUrlFormat() 공개 메소드

A Get URL format is like index.php?name1=value1&name2=value2 while a Path URL format is like index.php/name1/value1/name2/value. The separating character between name and value can be configured with {@link setUrlParamSeparator} and defaults to '/'. Changing the UrlFormat will affect {@link constructUrl} and how GET variables are parsed.
부터: 3.1.4
public setUrlFormat ( $value )

setUrlParamSeparator() 공개 메소드

public setUrlParamSeparator ( $value )

supportCustomUrl() 공개 메소드

부터: 3.1.1
public supportCustomUrl ( $getItems ) : boolean
리턴 boolean whether this pattern IS the one for constructing the URL with the specified GET items.

프로퍼티 상세

$_constants 보호되어 있는 프로퍼티

of constant parameters.
protected $_constants