class AbstractController implements EventTriggerableInterface, Serializable (View source)

The Controller class.

Traits

The BootableTrait class.

Methods

__construct(Input $input = null, AbstractPackage $package = null, Container $container = null)

Class init.

mixed
hmvc(string|AbstractController $task, Input|array $input = null, string $package = null)

Run HMVC to fetch content from other controller.

mixed
execute()

Execute the controller.

string
renderView(LayoutRenderableInterface|string $view, string $layout = 'default', string $engine = 'php', array $data = array())

Method to easily render view.

mixed
processSuccess(mixed $result)

Process success.

bool
processFailure(Exception $e = null)

Process failure.

getView(string $name = null, string $format = 'html', string $engine = null, bool $forceNew = false)

Get view object.

getModel(string $name = null, mixed $source = null, bool $forceNew = false)

getModel

setRedirect(string $url, int $code = 303, array $headers = array())

setRedirect

redirect(string $url, int $code = 303)

redirect

addMessage(string $messages, string $type = Bootstrap::MSG_INFO)

addMessage

mute(bool $bool = true)

mute

bool
isMute()

isMute

getPackage(int $backwards = 4)

Method to get property Package

setPackage(AbstractPackage $package)

Method to set property package

Container
getContainer()

Method to get property Container

setContainer(Container $container)

Method to set property container

getApplication()

getApplication

Input
getInput()

getInput

setInput(Input $input)

Method to set property input

string
getName(integer $backwards = 2)

Method to get property Name

setName(string $name)

Method to set property name

Structure
getConfig()

Method to get property Config

setConfig(Structure $config)

Method to set property config

getRouter()

getRouter

EventInterface
triggerEvent(EventInterface|string $event, array $args = array())

Trigger an event.

isHmvc(boolean $boolean = null)

Check this controller is in HMVC that we can close some behaviors.

ServerRequestInterface
getRequest()

Method to get property Request

setRequest(ServerRequestInterface $request)

Method to set property request

ResponseInterface
getResponse()

Method to get property Response

setResponse(ResponseInterface $response)

Method to set property response

mixed
getDataSource(string $key = 'database')

getDataSource

addMiddleware(callable|AbstractControllerMiddleware $middleware, int $priority = PriorityQueue::NORMAL)

addMiddleware

PriorityQueue
getMiddlewares()

Method to get property Middlewares

setMiddlewares(PriorityQueue $middlewares)

Method to set property middlewares

mixed
__get(string $name)

__get

string
serialize()

Serialize the controller.

unserialize(string $input)

Unserialize the controller.

Details

at line line 145
__construct(Input $input = null, AbstractPackage $package = null, Container $container = null)

Class init.

Parameters

Input $input
AbstractPackage $package
Container $container

at line line 194
mixed hmvc(string|AbstractController $task, Input|array $input = null, string $package = null)

Run HMVC to fetch content from other controller.

Parameters

string|AbstractController $task The task to exeiocute, must be controller object or string. The string format is Name\ActionController example: Page\GetController
Input|array $input The input for this task, can be array or Input object.
string $package The package for this controller, can be string or AbstractPackage.

Return Value

mixed

at line line 269
mixed execute()

Execute the controller.

Return Value

mixed Return executed result.

Exceptions

Exception
Throwable

at line line 379
string renderView(LayoutRenderableInterface|string $view, string $layout = 'default', string $engine = 'php', array $data = array())

Method to easily render view.

Parameters

LayoutRenderableInterface|string $view The view name or object.
string $layout The layout to render.
string $engine The engine of template.
array $data The data to set in view.

Return Value

string

Exceptions

LogicException

at line line 414
mixed processSuccess(mixed $result)

Process success.

Parameters

mixed $result

Return Value

mixed

at line line 426
bool processFailure(Exception $e = null)

Process failure.

Parameters

Exception $e

Return Value

bool

at line line 442
AbstractView|HtmlView getView(string $name = null, string $format = 'html', string $engine = null, bool $forceNew = false)

Get view object.

Parameters

string $name The view name.
string $format The view foramt.
string $engine The renderer template engine.
bool $forceNew The Force create new instance.

Return Value

AbstractView|HtmlView

Exceptions

Exception

at line line 521
ModelRepository getModel(string $name = null, mixed $source = null, bool $forceNew = false)

getModel

Parameters

string $name
mixed $source
bool $forceNew

Return Value

ModelRepository

Exceptions

Exception

at line line 588
AbstractController setRedirect(string $url, int $code = 303, array $headers = array())

setRedirect

Parameters

string $url
int $code
array $headers

Return Value

AbstractController

at line line 601
redirect(string $url, int $code = 303)

redirect

Parameters

string $url
int $code

at line line 618
AbstractController passRedirect(AbstractController $controller)

passRedirect

Parameters

AbstractController $controller

Return Value

AbstractController

at line line 638
AbstractController addMessage(string $messages, string $type = Bootstrap::MSG_INFO)

addMessage

Parameters

string $messages
string $type

Return Value

AbstractController

at line line 655
AbstractController mute(bool $bool = true)

mute

Parameters

bool $bool

Return Value

AbstractController

at line line 667
bool isMute()

isMute

Return Value

bool

at line line 679
AbstractPackage getPackage(int $backwards = 4)

Method to get property Package

Parameters

int $backwards

Return Value

AbstractPackage

at line line 735
AbstractController setPackage(AbstractPackage $package)

Method to set property package

Parameters

AbstractPackage $package

Return Value

AbstractController Return self to support chaining.

at line line 781
Container getContainer()

Method to get property Container

Return Value

Container

at line line 800
AbstractController setContainer(Container $container)

Method to set property container

Parameters

Container $container

Return Value

AbstractController Return self to support chaining.

at line line 813
WebApplication getApplication()

getApplication

Return Value

WebApplication

Exceptions

UnexpectedValueException

at line line 830
AbstractController setApplication(WebApplication $app)

setApplication

Parameters

WebApplication $app

Return Value

AbstractController

at line line 842
Input getInput()

getInput

Return Value

Input

at line line 859
AbstractController setInput(Input $input)

Method to set property input

Parameters

Input $input

Return Value

AbstractController Return self to support chaining.

at line line 873
string getName(integer $backwards = 2)

Method to get property Name

Parameters

integer $backwards

Return Value

string

at line line 890
AbstractController setName(string $name)

Method to set property name

Parameters

string $name

Return Value

AbstractController Return self to support chaining.

at line line 902
Structure getConfig()

Method to get property Config

Return Value

Structure

at line line 919
AbstractController setConfig(Structure $config)

Method to set property config

Parameters

Structure $config

Return Value

AbstractController Return self to support chaining.

at line line 931
PackageRouter getRouter()

getRouter

Return Value

PackageRouter

at line line 947
EventInterface triggerEvent(EventInterface|string $event, array $args = array())

Trigger an event.

Parameters

EventInterface|string $event The event object or name.
array $args The arguments to set in event.

Return Value

EventInterface The event after being passed through all listeners.

Exceptions

UnexpectedValueException

at line line 968
AbstractController|boolean isHmvc(boolean $boolean = null)

Check this controller is in HMVC that we can close some behaviors.

Parameters

boolean $boolean

Return Value

AbstractController|boolean

at line line 985
ServerRequestInterface getRequest()

Method to get property Request

Return Value

ServerRequestInterface

at line line 997
AbstractController setRequest(ServerRequestInterface $request)

Method to set property request

Parameters

ServerRequestInterface $request

Return Value

AbstractController Return self to support chaining.

at line line 1009
ResponseInterface getResponse()

Method to get property Response

Return Value

ResponseInterface

at line line 1021
AbstractController setResponse(ResponseInterface $response)

Method to set property response

Parameters

ResponseInterface $response

Return Value

AbstractController Return self to support chaining.

at line line 1035
mixed getDataSource(string $key = 'database')

getDataSource

Parameters

string $key

Return Value

mixed

at line line 1053
AbstractController addMiddleware(callable|AbstractControllerMiddleware $middleware, int $priority = PriorityQueue::NORMAL)

addMiddleware

Parameters

callable|AbstractControllerMiddleware $middleware
int $priority

Return Value

AbstractController

at line line 1065
PriorityQueue getMiddlewares()

Method to get property Middlewares

Return Value

PriorityQueue

at line line 1082
AbstractController setMiddlewares(PriorityQueue $middlewares)

Method to set property middlewares

Parameters

PriorityQueue $middlewares

Return Value

AbstractController Return self to support chaining.

at line line 1098
mixed __get(string $name)

__get

Parameters

string $name

Return Value

mixed

Exceptions

OutOfRangeException

at line line 1130
string serialize()

Serialize the controller.

Return Value

string The serialized controller.

at line line 1142
AbstractController unserialize(string $input)

Unserialize the controller.

Parameters

string $input The serialized controller.

Return Value

AbstractController Returns itself to support chaining.