PHP 클래스 FOF30\Controller\Controller

A generic MVC controller implementation
파일 보기 프로젝트 열기: akeeba/fof 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$autoRouting integer 0 = never 1 = frontend only 2 = backend only 3 = always
$cacheableTasks array The tasks for which caching should be enabled by default
$config array A cached copy of the class configuration parameter passed during initialisation
$container FOF30\Container\Container The container attached to this Controller
$csrfProtection integer 0 Disabled; no token checks are performed 1 Enabled; token checks are always performed 2 Only on HTML requests and backend; token checks are always performed in the back-end and in the front-end only when format is 'html' 3 Only on back-end; token checks are performed only in the back-end
$doTask string The mapped task that was performed.
$instance Controller Instance container.
$layout string The current layout; you can override it in the configuration
$message string Redirect message.
$messageType string Redirect message type.
$methods array Array of class methods
$modelInstances array[Model] An array of Model instances known to this Controller
$modelName string Overrides the name of the view's default model
$name array The name of the controller
$paths array The set of search directories for resources (views).
$redirect string URL for redirection.
$task string Current or most recently performed task.
$taskMap array Array of class methods to call for a given task.
$taskPrivileges array You can use the notation '@task' which means 'apply the same privileges as "task"'. If you create a reference back to yourself (e.g. 'mytask' => array('@mytask')) it will return TRUE.
$view string The current view name; you can override it in the configuration
$viewInstances array[View] An array of View instances known to this Controller
$viewName string Overrides the name of the view's default view

공개 메소드들

메소드 설명
__construct ( Container $container, array $config = [] ) : Controller Public constructor of the Controller class. You can pass the following variables in the $config array: name string The name of the Controller. Default: auto detect from the class name default_task string The task to use when none is specified. Default: main autoRouting int See the autoRouting property csrfProtection int See the csrfProtection property viewName string The view name. Default: the same as the controller name modelName string The model name. Default: the same as the controller name viewConfig array The configuration overrides for the View.
__get ( string $name ) : mixed | null Magic get method. Handles magic properties: $this->input mapped to $this->container->input
display ( boolean $cachable = false, boolean $urlparams = false, string $tpl = null ) : void Default task. Assigns a model to the view and asks the view to render itself.
execute ( string $task ) : null | boolean Executes a given controller task. The onBefore and onAfter methods are called automatically if they exist.
getModel ( string $name = null, array $config = [] ) : Model Returns a named Model object
getName ( ) : string Method to get the controller name
getTask ( ) : string Get the last task that is being performed or was most recently performed.
getTasks ( ) : array Gets the available tasks in the controller.
getView ( string $name = null, array $config = [] ) : View Returns a named View object
hasRedirect ( ) : boolean Returns true if there is a redirect set in the controller
main ( ) Alias to the display() task
redirect ( ) : boolean Redirects the browser or returns false if no redirect is set.
registerDefaultTask ( string $method ) : Controller Register the default task to perform if a mapping is not found.
registerTask ( string $task, string $method ) : Controller Register (map) a task to a method in the class.
setMessage ( string $text, string $type = 'message' ) : string Sets the internal message that is passed with a redirect
setModel ( string $modelName, Model &$model ) : void Pushes a named model to the Controller
setModelName ( string $modelName ) : void Set the name of the model to be used by this Controller
setRedirect ( string $url, string $msg = null, string $type = null ) : Controller Set a URL for browser redirection.
setView ( string $viewName, View &$view ) : void Pushes a named view to the Controller
setViewName ( string $viewName ) : void Set the name of the view to be used by this Controller
unregisterTask ( string $task ) : Controller Unregister (unmap) a task in the class.

보호된 메소드들

메소드 설명
checkACL ( string $area ) : boolean Checks if the current user has enough privileges for the requested ACL area.
csrfProtection ( ) : boolean Provides CSRF protection through the forced use of a secure token. If the token doesn't match the one in the session we return false.
getACLRuleFor ( string $area, array $oldAreas = [] ) : mixed Resolves @task and &callback notations for ACL privileges
triggerEvent ( string $event, array $arguments = [] ) : boolean Triggers an object-specific event. The event runs both locally –if a suitable method exists– and through the Joomla! plugin system. A true/false return value is expected. The first false return cancels the event.

메소드 상세

__construct() 공개 메소드

modelConfig array The configuration overrides for the Model.
public __construct ( Container $container, array $config = [] ) : Controller
$container FOF30\Container\Container The application container
$config array The configuration array
리턴 Controller

__get() 공개 메소드

Magic get method. Handles magic properties: $this->input mapped to $this->container->input
public __get ( string $name ) : mixed | null
$name string The property to fetch
리턴 mixed | null

checkACL() 보호된 메소드

Checks if the current user has enough privileges for the requested ACL area.
protected checkACL ( string $area ) : boolean
$area string The ACL area, e.g. core.manage.
리턴 boolean True if the user has the ACL privilege specified

csrfProtection() 보호된 메소드

Provides CSRF protection through the forced use of a secure token. If the token doesn't match the one in the session we return false.
protected csrfProtection ( ) : boolean
리턴 boolean

display() 공개 메소드

YOU MUST NOT USE THIS TASK DIRECTLY IN A URL. It is supposed to be used ONLY inside your code. In the URL, use task=browse instead.
public display ( boolean $cachable = false, boolean $urlparams = false, string $tpl = null ) : void
$cachable boolean Is this view cacheable?
$urlparams boolean Add your safe URL parameters (see further down in the code)
$tpl string The name of the template file to parse
리턴 void

execute() 공개 메소드

Executes a given controller task. The onBefore and onAfter methods are called automatically if they exist.
public execute ( string $task ) : null | boolean
$task string The task to execute, e.g. "browse"
리턴 null | boolean False on execution failure

getACLRuleFor() 보호된 메소드

Resolves @task and &callback notations for ACL privileges
protected getACLRuleFor ( string $area, array $oldAreas = [] ) : mixed
$area string The task notation to resolve
$oldAreas array Areas we've already been redirected from, used to detect circular references
리턴 mixed The resolved ACL privilege

getModel() 공개 메소드

Returns a named Model object
public getModel ( string $name = null, array $config = [] ) : Model
$name string The Model name. If null we'll use the modelName variable or, if it's empty, the same name as the Controller
$config array Configuration parameters to the Model. If skipped we will use $this->config
리턴 FOF30\Model\Model The instance of the Model known to this Controller

getName() 공개 메소드

The controller name is set by default parsed using the classname, or it can be set by passing a $config['name'] in the class constructor
public getName ( ) : string
리턴 string The name of the controller

getTask() 공개 메소드

Get the last task that is being performed or was most recently performed.
public getTask ( ) : string
리턴 string The task that is being performed or was most recently performed.

getTasks() 공개 메소드

Gets the available tasks in the controller.
public getTasks ( ) : array
리턴 array Array[i] of task names.

getView() 공개 메소드

Returns a named View object
public getView ( string $name = null, array $config = [] ) : View
$name string The Model name. If null we'll use the modelName variable or, if it's empty, the same name as the Controller
$config array Configuration parameters to the Model. If skipped we will use $this->config
리턴 FOF30\View\View The instance of the Model known to this Controller

hasRedirect() 공개 메소드

Returns true if there is a redirect set in the controller
public hasRedirect ( ) : boolean
리턴 boolean

main() 공개 메소드

Alias to the display() task
public main ( )

redirect() 공개 메소드

Redirects the browser or returns false if no redirect is set.
public redirect ( ) : boolean
리턴 boolean False if no redirect exists.

registerDefaultTask() 공개 메소드

Register the default task to perform if a mapping is not found.
public registerDefaultTask ( string $method ) : Controller
$method string The name of the method in the derived class to perform if a named task is not found.
리턴 Controller This object to support chaining.

registerTask() 공개 메소드

Register (map) a task to a method in the class.
public registerTask ( string $task, string $method ) : Controller
$task string The task.
$method string The name of the method in the derived class to perform for this task.
리턴 Controller This object to support chaining.

setMessage() 공개 메소드

Sets the internal message that is passed with a redirect
public setMessage ( string $text, string $type = 'message' ) : string
$text string Message to display on redirect.
$type string Message type. Optional, defaults to 'message'.
리턴 string Previous message

setModel() 공개 메소드

Pushes a named model to the Controller
public setModel ( string $modelName, Model &$model ) : void
$modelName string The name of the Model
$model FOF30\Model\Model The actual Model object to push
리턴 void

setModelName() 공개 메소드

Set the name of the model to be used by this Controller
public setModelName ( string $modelName ) : void
$modelName string The name of the model
리턴 void

setRedirect() 공개 메소드

Set a URL for browser redirection.
public setRedirect ( string $url, string $msg = null, string $type = null ) : Controller
$url string URL to redirect to.
$msg string Message to display on redirect. Optional, defaults to value set internally by controller, if any.
$type string Message type. Optional, defaults to 'message' or the type set by a previous call to setMessage.
리턴 Controller This object to support chaining.

setView() 공개 메소드

Pushes a named view to the Controller
public setView ( string $viewName, View &$view ) : void
$viewName string The name of the View
$view FOF30\View\View The actual View object to push
리턴 void

setViewName() 공개 메소드

Set the name of the view to be used by this Controller
public setViewName ( string $viewName ) : void
$viewName string The name of the view
리턴 void

triggerEvent() 보호된 메소드

EXAMPLE Component: com_foobar, Object name: item, Event: onBeforeSomething, Arguments: array(123, 456) The event calls: 1. $this->onBeforeSomething(123, 456) 2. $this->checkACL('@something') if there is no onBeforeSomething and the event starts with onBefore 3. Joomla! plugin event onComFoobarControllerItemBeforeSomething($this, 123, 456)
protected triggerEvent ( string $event, array $arguments = [] ) : boolean
$event string The name of the event, typically named onPredicateVerb e.g. onBeforeKick
$arguments array The arguments to pass to the event handlers
리턴 boolean

unregisterTask() 공개 메소드

Unregister (unmap) a task in the class.
public unregisterTask ( string $task ) : Controller
$task string The task.
리턴 Controller This object to support chaining.

프로퍼티 상세

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

0 = never 1 = frontend only 2 = backend only 3 = always
protected int $autoRouting
리턴 integer

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

The tasks for which caching should be enabled by default
protected array $cacheableTasks
리턴 array

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

A cached copy of the class configuration parameter passed during initialisation
protected array $config
리턴 array

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

The container attached to this Controller
protected Container,FOF30\Container $container
리턴 FOF30\Container\Container

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

0 Disabled; no token checks are performed 1 Enabled; token checks are always performed 2 Only on HTML requests and backend; token checks are always performed in the back-end and in the front-end only when format is 'html' 3 Only on back-end; token checks are performed only in the back-end
protected int $csrfProtection
리턴 integer

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

The mapped task that was performed.
protected string $doTask
리턴 string

$instance 보호되어 있는 정적으로 프로퍼티

Instance container.
protected static Controller,FOF30\Controller $instance
리턴 Controller

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

The current layout; you can override it in the configuration
protected string $layout
리턴 string

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

Redirect message.
protected string $message
리턴 string

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

Redirect message type.
protected string $messageType
리턴 string

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

Array of class methods
protected array $methods
리턴 array

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

An array of Model instances known to this Controller
protected array[Model] $modelInstances
리턴 array[Model]

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

Overrides the name of the view's default model
protected string $modelName
리턴 string

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

The name of the controller
protected array $name
리턴 array

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

The set of search directories for resources (views).
protected array $paths
리턴 array

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

URL for redirection.
protected string $redirect
리턴 string

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

Current or most recently performed task.
protected string $task
리턴 string

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

Array of class methods to call for a given task.
protected array $taskMap
리턴 array

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

You can use the notation '@task' which means 'apply the same privileges as "task"'. If you create a reference back to yourself (e.g. 'mytask' => array('@mytask')) it will return TRUE.
protected array $taskPrivileges
리턴 array

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

The current view name; you can override it in the configuration
protected string $view
리턴 string

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

An array of View instances known to this Controller
protected array[View] $viewInstances
리턴 array[View]

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

Overrides the name of the view's default view
protected string $viewName
리턴 string