PHP Класс Voodoo\Core\Controller

Наследование: use trait Voodoo\Core\Controller\TAnnotation, use trait Voodoo\Core\Controller\TPagination
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$abort boolean Flag to abort the execution of a controller
$actionName string The action's name being called
$actionView The action view to use
$controllerName String The controller's name
$httpStatusCode integer The default status code
$moduleName String The module name
$namespace string The full namespace of the controller
$reflection Reflection The reflection of the called class

Открытые методы

Метод Описание
__construct ( array $segments = [] ) final construct so no other class can override it To load something in the constructor, use init()
__destruct ( ) It's a wrap By default, when the destructor is called, it will render the views To disable view, in your controller set: $this->disableView(true)
__toString ( ) : string Return the full name of the class
actionIndex ( ) This is the index action.
catchNumericSegment ( ) : mixed To catch the first numeric value from the URL segment. ie: /music/rap/12573/Where-Have-You-Been. Will return 12573
disableView ( $bool = true ) : Controller To enable render view. on __destruct, it will render the view, otherwise it's up to the controller to launch it.
getAction ( string $action = "Index" ) : Controller Load an action by providing just the name without the Action suffix.
getActionMethodName ( ) : string Return the full name of the method
getActionName ( ) : string Return the last action name saved
getActionUrl ( ) : string Return the action url
getApplicationDir ( ) : string Get the application
getBaseDir ( ) : string Return the root dir relative to the Application dir Use it to include files, or get relative path of file
getBaseUrl ( ) : string Return the root url which will properly format the url so it adds or not ? to make the relative link
getConfig ( type $key = null ) : mixed To access config info
getControllerName ( ) : string Return the controller's name
getControllerUrl ( ) : string Return the url for the controller
getIp ( ) : string Return the user agent ip
getModuleDir ( ) : string Get the module directory
getModuleName ( ) : string Return the module's name
getModuleNamespace ( )
getModuleUrl ( ) : string Return the URL of the module
getParam ( string $key = null, mixed $default = null ) : mixed Get POST or GET param
getParams ( ) : Array Return all the request params of GET and POST
getRequestURI ( ) : string To get the request uri. It includes everything in the URI
getSegment ( $key = null, $offset ) : mixed Segements are part of the URL separated by / ie: /gummy/bear/?q=hello 'gummy' and 'bear' are segments.
getSiteUrl ( ) : string Return the site url itself
isAjax ( ) : boolean CHeck request if it's an ajax request
isGet ( ) : boolean Bool if the request method is a GET
isPost ( ) : boolean Bool if the request method is a POST
redirect ( $url = "", integer $httpCode = 302 ) To redirect the page to a new page
setHttpCode ( integer $code = 200 ) : Voodoo\Core\Controller Set the http status code
toDate ( mixed $datetime, $format = null ) : string Return a formatted date
toFriendlyUrl ( type $url ) : string Return a string to friendly url

Защищенные методы

Метод Описание
_exit ( ) : void To completely exit the application just like calling exit().
abort ( ) : Controller Abort the execution of finalize() and renderView() of the application in __destruct
afterAction ( ) : Controller afterAction() Execute the method after the Action is executed
beforeAction ( ) : Controller beforeAction() Execute the method before the Action is executed
finalize ( ) : Controller finalize() Code to excute before rendering
forwardTo ( string $controllerName, array $params = [] ) : Controller forward, like getController, forward the current controller to a new controller and allows it to render the view, while it deactivate the current controller view.
getActionView ( ) : type Return the action view
getController ( $controllerName, array $params = [] ) : Voodoo\Core\controller To access another controller without rendering it
init ( ) : Controller init() __construct is and can't be overriden by any child class init() lets you put code that could be executed in __construct()
renderView ( boolean $echoView = true ) : boolean | string To render the controller's view
setActionName ( string $action ) Set the action name
setActionView ( type $view ) : Controller Set the action view to be displayed
view ( array $dataModel = null ) : Voodoo\Core\View Return the View instance
viewExists ( ) : boolean Verify if the view directory exists

Приватные методы

Метод Описание
dasherizeUrl ( type $str ) : string Dasherize part for a url
getParentNamespace ( type $namespace ) : string Return the parent namespace

Описание методов

__construct() закрытый публичный Метод

final construct so no other class can override it To load something in the constructor, use init()
final public __construct ( array $segments = [] )
$segments array

__destruct() закрытый публичный Метод

It's a wrap By default, when the destructor is called, it will render the views To disable view, in your controller set: $this->disableView(true)
final public __destruct ( )

__toString() публичный Метод

Return the full name of the class
public __toString ( ) : string
Результат string

_exit() закрытый защищенный Метод

__destruct will be invoked, but will not finalize() and renderView() Calling PHP exit() will still cause finalize() and renderView() to execute
final protected _exit ( ) : void
Результат void

abort() закрытый защищенный Метод

Abort the execution of finalize() and renderView() of the application in __destruct
final protected abort ( ) : Controller
Результат Controller

actionIndex() абстрактный публичный Метод

It is loaded by default or an action is missing Every controller requires it
abstract public actionIndex ( )

afterAction() защищенный Метод

afterAction() Execute the method after the Action is executed
protected afterAction ( ) : Controller
Результат Controller

beforeAction() защищенный Метод

beforeAction() Execute the method before the Action is executed
protected beforeAction ( ) : Controller
Результат Controller

catchNumericSegment() публичный Метод

To catch the first numeric value from the URL segment. ie: /music/rap/12573/Where-Have-You-Been. Will return 12573
public catchNumericSegment ( ) : mixed
Результат mixed (int | null)

disableView() публичный Метод

To enable render view. on __destruct, it will render the view, otherwise it's up to the controller to launch it.
public disableView ( $bool = true ) : Controller
Результат Controller

finalize() защищенный Метод

finalize() Code to excute before rendering
protected finalize ( ) : Controller
Результат Controller

forwardTo() защищенный Метод

All the settings and params will be forwarded to the new controller
protected forwardTo ( string $controllerName, array $params = [] ) : Controller
$controllerName string
$params array
Результат Controller

getAction() публичный Метод

Its purpose is to set the action to be rendered. You still can access the method the normal way $this->action_index i.e $this->getAction("index");
public getAction ( string $action = "Index" ) : Controller
$action string - The action name without Action as suffix. ie: action_index() = getAction("index")
Результат Controller NOTE: actions make use of the annotations @action_view @use_layout @request @format

getActionMethodName() публичный Метод

Return the full name of the method
public getActionMethodName ( ) : string
Результат string

getActionName() публичный Метод

Return the last action name saved
public getActionName ( ) : string
Результат string

getActionUrl() публичный Метод

Return the action url
public getActionUrl ( ) : string
Результат string

getActionView() защищенный Метод

Return the action view
protected getActionView ( ) : type
Результат type

getApplicationDir() публичный Метод

Get the application
public getApplicationDir ( ) : string
Результат string

getBaseDir() публичный Метод

Return the root dir relative to the Application dir Use it to include files, or get relative path of file
public getBaseDir ( ) : string
Результат string

getBaseUrl() публичный Метод

Return the root url which will properly format the url so it adds or not ? to make the relative link
public getBaseUrl ( ) : string
Результат string

getConfig() публичный Метод

To access config info
public getConfig ( type $key = null ) : mixed
$key type
Результат mixed

getController() защищенный Метод

To access another controller without rendering it
protected getController ( $controllerName, array $params = [] ) : Voodoo\Core\controller
$params array
Результат Voodoo\Core\controller

getControllerName() публичный Метод

Return the controller's name
public getControllerName ( ) : string
Результат string

getControllerUrl() публичный Метод

Return the url for the controller
public getControllerUrl ( ) : string
Результат string

getIp() публичный Метод

Return the user agent ip
public getIp ( ) : string
Результат string

getModuleDir() публичный Метод

Get the module directory
public getModuleDir ( ) : string
Результат string

getModuleName() публичный Метод

Return the module's name
public getModuleName ( ) : string
Результат string

getModuleNamespace() публичный Метод

public getModuleNamespace ( )

getModuleUrl() публичный Метод

Return the URL of the module
public getModuleUrl ( ) : string
Результат string

getParam() публичный Метод

Get POST or GET param
public getParam ( string $key = null, mixed $default = null ) : mixed
$key string
$default mixed
Результат mixed

getParams() публичный Метод

Return all the request params of GET and POST
public getParams ( ) : Array
Результат Array

getRequestURI() публичный Метод

To get the request uri. It includes everything in the URI
public getRequestURI ( ) : string
Результат string

getSegment() публичный Метод

Segements are part of the URL separated by / ie: /gummy/bear/?q=hello 'gummy' and 'bear' are segments.
public getSegment ( $key = null, $offset ) : mixed
Результат mixed

getSiteUrl() публичный Метод

Return the site url itself
public getSiteUrl ( ) : string
Результат string

init() защищенный Метод

init() __construct is and can't be overriden by any child class init() lets you put code that could be executed in __construct()
protected init ( ) : Controller
Результат Controller

isAjax() публичный Метод

CHeck request if it's an ajax request
public isAjax ( ) : boolean
Результат boolean

isGet() публичный Метод

Bool if the request method is a GET
public isGet ( ) : boolean
Результат boolean

isPost() публичный Метод

Bool if the request method is a POST
public isPost ( ) : boolean
Результат boolean

redirect() публичный Метод

To redirect the page to a new page
public redirect ( $url = "", integer $httpCode = 302 )
$httpCode integer

renderView() защищенный Метод

To render the controller's view
protected renderView ( boolean $echoView = true ) : boolean | string
$echoView boolean - to print the view or just return it
Результат boolean | string | string

setActionName() защищенный Метод

Set the action name
protected setActionName ( string $action )
$action string

setActionView() защищенный Метод

Set the action view to be displayed
protected setActionView ( type $view ) : Controller
$view type
Результат Controller

setHttpCode() публичный Метод

Set the http status code
public setHttpCode ( integer $code = 200 ) : Voodoo\Core\Controller
$code integer
Результат Voodoo\Core\Controller

toDate() публичный Метод

Return a formatted date
public toDate ( mixed $datetime, $format = null ) : string
$datetime mixed
Результат string

toFriendlyUrl() публичный Метод

Return a string to friendly url
public toFriendlyUrl ( type $url ) : string
$url type
Результат string

view() защищенный Метод

Return the View instance
protected view ( array $dataModel = null ) : Voodoo\Core\View
$dataModel array - Data model to assign to the view
Результат Voodoo\Core\View

viewExists() защищенный Метод

Verify if the view directory exists
protected viewExists ( ) : boolean
Результат boolean

Описание свойств

$abort защищенное свойство

Flag to abort the execution of a controller
protected bool $abort
Результат boolean

$actionName защищенное свойство

The action's name being called
protected string $actionName
Результат string

$actionView защищенное свойство

The action view to use
protected $actionView

$controllerName защищенное свойство

The controller's name
protected String $controllerName
Результат String

$httpStatusCode защищенное свойство

The default status code
protected int $httpStatusCode
Результат integer

$moduleName защищенное свойство

The module name
protected String $moduleName
Результат String

$namespace защищенное свойство

The full namespace of the controller
protected string $namespace
Результат string

$reflection защищенное свойство

The reflection of the called class
protected Reflection $reflection
Результат Reflection