PHP 클래스 RtNode, recess

pages/ -> matches /pages/ pages/$id -> matches /pages/1 ... (id => 1) pages/slug/$slug -> matches /pages/slug/some-slug-here (slug => some-slug-here) For the purposes of this class a URI path is broken into parts delimited with a '/'. There are two kinds of path parts: static and parametric. Static matches have precedence over parametric matches. For example, if you have the following routes: (1) /pages/$page_title/ (2) /pages/a-page/ (3) /pages/$page_title/$id A request of "/pages/a-page/" will match (2) and the result will not contain an argument. A request of "/pages/b-page/" will match (1) and the result will contain argument ("page_title" => "b_page") A request of "/pages/a-page/1" will match (3) with result arguments ("page_title" => "a_page", "id" => "1") Note: Because routing trees are serialized and unserialized frequently I am breaking the naming conventions and using short, one-letter member names.
파일 보기 프로젝트 열기: KrisJordan/recess 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$c
$m (c)ondition
$p (s)tatic children
$s (m)ethods

공개 메소드들

메소드 설명
__set_state ( $array )
addRoute ( $app, Route $route, $prefix ) Used to add a route to the routing tree.
filterPath ( $input )
findRouteFor ( Request $request ) : RoutingResult Traverses children recursively to find a matching route. First looks to see if a static (non-parametric, i.e. /this_is_static/ vs. /$this_is_dynamic/) match exists. If not, we match against dynamic children. We reverse and step backwards through the array because $index > 0 is less costly than $index < count($parts) in PHP.
getMethods ( )
getParametricPaths ( )
getStaticPaths ( )
matches ( $path )

비공개 메소드들

메소드 설명
addRouteRecursively ( &$pathParts, $index, $route ) : FindRouteResult The recursive method powering addRouteFor(Request).
findRouteRecursively ( &$pathParts, $index, &$method ) : RoutingResult The recursive method powering findRouteFor(Request).
getRevesedPathParts ( $path ) Explodes a string by forward slashes, removes empty first/last node and finally reverses the array.

메소드 상세

__set_state() 공개 정적인 메소드

public static __set_state ( $array )

addRoute() 공개 메소드

Used to add a route to the routing tree.
public addRoute ( $app, Route $route, $prefix )
$route Route

filterPath() 공개 정적인 메소드

public static filterPath ( $input )

findRouteFor() 공개 메소드

Traverses children recursively to find a matching route. First looks to see if a static (non-parametric, i.e. /this_is_static/ vs. /$this_is_dynamic/) match exists. If not, we match against dynamic children. We reverse and step backwards through the array because $index > 0 is less costly than $index < count($parts) in PHP.
public findRouteFor ( Request $request ) : RoutingResult
$request Request
리턴 RoutingResult

getMethods() 공개 메소드

public getMethods ( )

getParametricPaths() 공개 메소드

public getParametricPaths ( )

getStaticPaths() 공개 메소드

public getStaticPaths ( )

matches() 공개 메소드

public matches ( $path )

프로퍼티 상세

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

protected $c

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

(c)ondition
protected $m

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

(s)tatic children
protected $p

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

(m)ethods
protected $s