PHP 클래스 Tools\Controller\Component\CommonComponent

저자: Mark Scherer
상속: extends Shim\Controller\Component\Component
파일 보기 프로젝트 열기: dereuromark/cakephp-tools

공개 메소드들

메소드 설명
autoPostRedirect ( mixed $whereTo, boolean $conditionalAutoRedirect = true, integer $status = 302 ) : Response Combine auto with post also allows whitelisting certain actions for autoRedirect (use Controller::$autoRedirectActions)
autoRedirect ( mixed $whereTo, boolean $allowSelf = false, integer $status = 302 ) : Response Smart Referer Redirect - will try to use an existing referer first otherwise it will use the default url
completeRedirect ( mixed | null $url = null, integer | null $status = 302 ) : Response Automatically add missing URL parts of the current URL including - querystring (especially for 3.x then) - passed params
currentUrl ( boolean $asString = false ) : mixed Returns current url (with all missing params automatically added).
defaultUrlParams ( ) : array Returns defaultUrlParams including configured prefixes.
forceCache ( integer $seconds = HOUR ) : void Set headers to cache this request.
getPassedParam ( mixed $var, mixed $default = null ) : mixed Used to get the value of a passed param.
isForeignReferer ( string | null $ref = null ) : boolean Referrer checking (where does the user come from) Only returns true for a valid external referrer.
isPosted ( ) : boolean Convenience method to check on POSTED data.
listActions ( ) : array List all direct actions of a controller
loadComponent ( string $component, array $config = [], boolean $callbacks = true ) : void Add component just in time (inside actions - only when needed) aware of plugins and config array (if passed)
loadHelper ( mixed $helpers = [] ) : void Add helper just in time (inside actions - only when needed) aware of plugins
postRedirect ( mixed $whereTo, integer $status = 302 ) : Response Should be a 303, but: Note: Many pre-HTTP/1.1 user agents do not understand the 303 status. When interoperability with such clients is a concern, the 302 status code may be used instead, since most user agents react to a 302 response as described here for 303.
startup ( Cake\Event\Event $event ) : void For this helper the controller has to be passed as reference for manual startup with $disableStartup = true (requires this to be called prior to any other method)

메소드 상세

autoPostRedirect() 공개 메소드

Combine auto with post also allows whitelisting certain actions for autoRedirect (use Controller::$autoRedirectActions)
public autoPostRedirect ( mixed $whereTo, boolean $conditionalAutoRedirect = true, integer $status = 302 ) : Response
$whereTo mixed URL
$conditionalAutoRedirect boolean false to skip whitelisting
$status integer
리턴 Cake\Network\Response

autoRedirect() 공개 메소드

Smart Referer Redirect - will try to use an existing referer first otherwise it will use the default url
public autoRedirect ( mixed $whereTo, boolean $allowSelf = false, integer $status = 302 ) : Response
$whereTo mixed URL
$allowSelf boolean if redirect to the same controller/action (url) is allowed
$status integer
리턴 Cake\Network\Response

completeRedirect() 공개 메소드

Automatically add missing URL parts of the current URL including - querystring (especially for 3.x then) - passed params
public completeRedirect ( mixed | null $url = null, integer | null $status = 302 ) : Response
$url mixed | null
$status integer | null
리턴 Cake\Network\Response

currentUrl() 공개 메소드

Necessary for Router::url() and comparison of urls to work.
public currentUrl ( boolean $asString = false ) : mixed
$asString boolean Defaults to false = array
리턴 mixed URL

defaultUrlParams() 공개 정적인 메소드

Returns defaultUrlParams including configured prefixes.
public static defaultUrlParams ( ) : array
리턴 array URL params

forceCache() 공개 메소드

Opposite of Controller::disableCache()
public forceCache ( integer $seconds = HOUR ) : void
$seconds integer
리턴 void

getPassedParam() 공개 메소드

Used to get the value of a passed param.
public getPassedParam ( mixed $var, mixed $default = null ) : mixed
$var mixed
$default mixed
리턴 mixed

isForeignReferer() 공개 메소드

Referrer checking (where does the user come from) Only returns true for a valid external referrer.
public isForeignReferer ( string | null $ref = null ) : boolean
$ref string | null Referer
리턴 boolean Success

isPosted() 공개 메소드

Doesn't matter if it's POST, PUT or PATCH. Note that you can also use request->is(array('post', 'put', 'patch') directly.
public isPosted ( ) : boolean
리턴 boolean If it is of type POST/PUT/PATCH

listActions() 공개 메소드

List all direct actions of a controller
public listActions ( ) : array
리턴 array Actions

loadComponent() 공개 메소드

Add component just in time (inside actions - only when needed) aware of plugins and config array (if passed)
public loadComponent ( string $component, array $config = [], boolean $callbacks = true ) : void
$component string Component
$config array
$callbacks boolean (defaults to true)
리턴 void

loadHelper() 공개 메소드

Add helper just in time (inside actions - only when needed) aware of plugins
사용 중단: In 3.x, but kept for easier migration for now. Will be removed in the future.
public loadHelper ( mixed $helpers = [] ) : void
$helpers mixed (single string or multiple array)
리턴 void

postRedirect() 공개 메소드

TODO: change to 303 with backwardscompatability for older browsers...
또한 보기: http://en.wikipedia.org/wiki/Post/Redirect/Get
public postRedirect ( mixed $whereTo, integer $status = 302 ) : Response
$whereTo mixed URL
$status integer
리턴 Cake\Network\Response

startup() 공개 메소드

For this helper the controller has to be passed as reference for manual startup with $disableStartup = true (requires this to be called prior to any other method)
public startup ( Cake\Event\Event $event ) : void
$event Cake\Event\Event
리턴 void