class GetController extends AbstractController (View source)

The GetController 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

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

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

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

Class init.

Parameters

Input $input
AbstractPackage $package
Container $container

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

mixed execute()

Execute the controller.

Return Value

mixed Return executed result.

Exceptions

Exception
Throwable

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

mixed processSuccess(mixed $result)

Process success.

Parameters

mixed $result

Return Value

mixed

bool processFailure(Exception $e = null)

Process failure.

Parameters

Exception $e

Return Value

bool

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

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

getModel

Parameters

string $name
mixed $source
bool $forceNew

Return Value

ModelRepository

Exceptions

Exception

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

setRedirect

Parameters

string $url
int $code
array $headers

Return Value

AbstractController

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

redirect

Parameters

string $url
int $code

AbstractController passRedirect(AbstractController $controller)

passRedirect

Parameters

AbstractController $controller

Return Value

AbstractController

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

addMessage

Parameters

string $messages
string $type

Return Value

AbstractController

AbstractController mute(bool $bool = true)

mute

Parameters

bool $bool

Return Value

AbstractController

bool isMute()

isMute

Return Value

bool

AbstractPackage getPackage(int $backwards = 4)

Method to get property Package

Parameters

int $backwards

Return Value

AbstractPackage

AbstractController setPackage(AbstractPackage $package)

Method to set property package

Parameters

AbstractPackage $package

Return Value

AbstractController Return self to support chaining.

Container getContainer()

Method to get property Container

Return Value

Container

AbstractController setContainer(Container $container)

Method to set property container

Parameters

Container $container

Return Value

AbstractController Return self to support chaining.

WebApplication getApplication()

getApplication

Return Value

WebApplication

Exceptions

UnexpectedValueException

AbstractController setApplication(WebApplication $app)

setApplication

Parameters

WebApplication $app

Return Value

AbstractController

Input getInput()

getInput

Return Value

Input

AbstractController setInput(Input $input)

Method to set property input

Parameters

Input $input

Return Value

AbstractController Return self to support chaining.

string getName(integer $backwards = 2)

Method to get property Name

Parameters

integer $backwards

Return Value

string

AbstractController setName(string $name)

Method to set property name

Parameters

string $name

Return Value

AbstractController Return self to support chaining.

Structure getConfig()

Method to get property Config

Return Value

Structure

AbstractController setConfig(Structure $config)

Method to set property config

Parameters

Structure $config

Return Value

AbstractController Return self to support chaining.

PackageRouter getRouter()

getRouter

Return Value

PackageRouter

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

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

ServerRequestInterface getRequest()

Method to get property Request

Return Value

ServerRequestInterface

AbstractController setRequest(ServerRequestInterface $request)

Method to set property request

Parameters

ServerRequestInterface $request

Return Value

AbstractController Return self to support chaining.

ResponseInterface getResponse()

Method to get property Response

Return Value

ResponseInterface

AbstractController setResponse(ResponseInterface $response)

Method to set property response

Parameters

ResponseInterface $response

Return Value

AbstractController Return self to support chaining.

mixed getDataSource(string $key = 'database')

getDataSource

Parameters

string $key

Return Value

mixed

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

addMiddleware

Parameters

callable|AbstractControllerMiddleware $middleware
int $priority

Return Value

AbstractController

PriorityQueue getMiddlewares()

Method to get property Middlewares

Return Value

PriorityQueue

AbstractController setMiddlewares(PriorityQueue $middlewares)

Method to set property middlewares

Parameters

PriorityQueue $middlewares

Return Value

AbstractController Return self to support chaining.

mixed __get(string $name)

__get

Parameters

string $name

Return Value

mixed

Exceptions

OutOfRangeException

string serialize()

Serialize the controller.

Return Value

string The serialized controller.

AbstractController unserialize(string $input)

Unserialize the controller.

Parameters

string $input The serialized controller.

Return Value

AbstractController Returns itself to support chaining.