PHP 클래스 Zaphpa_Middleware, zaphpa

파일 보기 프로젝트 열기: zaphpa/zaphpa

공개 프로퍼티들

프로퍼티 타입 설명
$context
$routes
$scope

공개 메소드들

메소드 설명
preprocess ( &$router ) Preprocess. This is where you'd add new routes *
prerender ( &$buffer ) This is your chance to override output. It can be called multiple times for each ->flush() invocation! *
preroute ( &$req, &$res ) Preroute. This is where you would aler request, or implement things like: security etc. *
restrict ( string $hook, $methods, $route ) : Zaphpa_Middlware Restrict a middleware hook to certain paths and HTTP methods.
shouldRun ( string $hook ) : boolean Determine whether the current route has any route restrictions for this middleware.

메소드 상세

preprocess() 공개 메소드

Preprocess. This is where you'd add new routes *
public preprocess ( &$router )

prerender() 공개 메소드

This is your chance to override output. It can be called multiple times for each ->flush() invocation! *
public prerender ( &$buffer )

preroute() 공개 메소드

Preroute. This is where you would aler request, or implement things like: security etc. *
public preroute ( &$req, &$res )

restrict() 공개 메소드

No actual restriction takes place in this method. We simply place the $methods array into $this->scope, keyed by its $hook.
public restrict ( string $hook, $methods, $route ) : Zaphpa_Middlware
$hook string A middleware hook, expecting either 'preroute' or 'prerender'. @param array $rules An associative array of paths and their allowed methods: - path: A URL route string, the same as are used in $router->addRoute(). - methods: An array of HTTP methods that are allowed, or an '*' to match all methods. @return Zaphpa_Middlware The current middleware object, to allow for chaining a la jQuery.
리턴 Zaphpa_Middlware

shouldRun() 공개 메소드

If the middleware has restrictions for a given $hook, we check for the current route. If the current route is in the list of allowed paths, we check that the request method is also allowed. Otherwise, the current route needn't run the $hook.
public shouldRun ( string $hook ) : boolean
$hook string A middleware hook, expecting either 'preroute' or 'prerender'. @return bool Whether the current route should run $hook.
리턴 boolean

프로퍼티 상세

$context 공개적으로 정적으로 프로퍼티

public static $context

$routes 공개적으로 정적으로 프로퍼티

public static $routes

$scope 공개적으로 프로퍼티

public $scope