abstract class Yaf_Action_Abstract extends Yaf_Controller_Abstract (View source)

A action can be defined in a separate file in Yaf(see Yaf_Controller_Abstract). that is a action method can also be a Yaf_Action_Abstract class.


Since there should be a entry point which can be called by Yaf (as of PHP 5.3, there is a new magic method __invoke, but Yaf is not only works with PHP 5.3+, Yaf choose another magic method execute), you must implement the abstract method Yaf_Action_Abstract::execute() in your custom action class.

Properties

array $actions from  Yaf_Controller_Abstract
protected string $_module from  Yaf_Controller_Abstract
protected string $_name from  Yaf_Controller_Abstract
protected Yaf_Request_Abstract $_request from  Yaf_Controller_Abstract
protected Yaf_Response_Abstract $_response from  Yaf_Controller_Abstract
protected array $_invoke_args from  Yaf_Controller_Abstract
protected Yaf_View_Interface $_view from  Yaf_Controller_Abstract
protected Yaf_Controller_Abstract $_controller

Methods

string|null|bool
render(string $tpl, array|null $parameters = null)

No description

bool
display(string $tpl, array|null $parameters = null)

No description

getRequest()

retrieve current request object

getResponse()

retrieve current response object

string
getModuleName()

get the controller's module name

getView()

retrieve view engine

string|null
getName()

No description

initView(array|null $options = null) deprecated

No description

bool
setViewpath(string $view_directory)

No description

string
getViewpath()

No description

bool
forward(string $module, string $controller = null, string $action = null, array|null $parameters = null)

forward current execution process to other action.


Note:

this method doesn't switch to the destination action immediately, it will take place after current flow finish.


Notice, there are 3 available method signatures:

Yaf_Controller_Abstract::forward ( string $module , string $controller , string $action [, array $parameters ] )

Yaf_Controller_Abstract::forward ( string $controller , string $action [, array $parameters ] )

Yaf_Controller_Abstract::forward ( string $action [, array $parameters ] )

bool
redirect(string $url)

redirect to a URL by sending a 302 header

array
getInvokeArgs()

No description

mixed
getInvokeArg(string $name)

No description

void
init()

Yaf_Controller_Abstract::__construct() is final, which means users can not override it. but users can define Yaf_Controller_Abstract::init(), which will be called after controller object is instantiated.

__construct(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response, Yaf_View_Interface $view, array|null $args = null)

Yaf_Controller_Abstract::__construct() is final, which means it can not be overridden. You may want to see Yaf_Controller_Abstract::init() instead.

mixed
execute(mixed ...$args)

user should always define this method for a action, this is the entry point of an action. Yaf_Action_Abstract::execute() may have arguments.


Note:

The value retrieved from the request is not safe. you should do some filtering work before you use it.

getController()

retrieve current controller object.

string
getControllerName()

No description

Details

protected string|null|bool render(string $tpl, array|null $parameters = null)

No description

Parameters

string $tpl
array|null $parameters

Return Value

string|null|bool

protected bool display(string $tpl, array|null $parameters = null)

No description

Parameters

string $tpl
array|null $parameters

Return Value

bool

Yaf_Request_Abstract getRequest()

retrieve current request object

Return Value

Yaf_Request_Abstract

Yaf_Response_Abstract getResponse()

retrieve current response object

Return Value

Yaf_Response_Abstract

string getModuleName()

get the controller's module name

Return Value

string

Yaf_View_Interface getView()

retrieve view engine

Return Value

Yaf_View_Interface

string|null getName()

No description

Return Value

string|null

Yaf_Response_Abstract initView(array|null $options = null) deprecated

deprecated not_implemented

No description

Parameters

array|null $options

Return Value

Yaf_Response_Abstract

bool setViewpath(string $view_directory)

No description

Parameters

string $view_directory

Return Value

bool

string getViewpath()

No description

Return Value

string

bool forward(string $module, string $controller = null, string $action = null, array|null $parameters = null)

forward current execution process to other action.


Note:

this method doesn't switch to the destination action immediately, it will take place after current flow finish.


Notice, there are 3 available method signatures:

Yaf_Controller_Abstract::forward ( string $module , string $controller , string $action [, array $parameters ] )

Yaf_Controller_Abstract::forward ( string $controller , string $action [, array $parameters ] )

Yaf_Controller_Abstract::forward ( string $action [, array $parameters ] )

Parameters

string $module

destination module name, if NULL was given, then default module name is assumed

string $controller

destination controller name

string $action

destination action name

array|null $parameters

calling arguments

Return Value

bool

return FALSE on failure

bool redirect(string $url)

redirect to a URL by sending a 302 header

Parameters

string $url

a location URL

Return Value

bool

array getInvokeArgs()

No description

Return Value

array

mixed getInvokeArg(string $name)

No description

Parameters

string $name

Return Value

mixed

void init()

Yaf_Controller_Abstract::__construct() is final, which means users can not override it. but users can define Yaf_Controller_Abstract::init(), which will be called after controller object is instantiated.

Return Value

void

__construct(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response, Yaf_View_Interface $view, array|null $args = null)

Yaf_Controller_Abstract::__construct() is final, which means it can not be overridden. You may want to see Yaf_Controller_Abstract::init() instead.

Parameters

Yaf_Request_Abstract $request
Yaf_Response_Abstract $response
Yaf_View_Interface $view
array|null $args

See also

Yaf_Controller_Abstract::init

abstract mixed execute(mixed ...$args)

user should always define this method for a action, this is the entry point of an action. Yaf_Action_Abstract::execute() may have arguments.


Note:

The value retrieved from the request is not safe. you should do some filtering work before you use it.

Parameters

mixed ...$args

Return Value

mixed

Yaf_Controller_Abstract getController()

retrieve current controller object.

string getControllerName()

No description

Return Value

string