TraitController
Adds some helpful functions and makes it possible to suppress output of a parent controller.
Table of Contents
Properties
Methods
- getLastError() : mixed
- Returns the last error.
- addTopMessage() : mixed
- Adds a message shown at the top of the page; stored in the session.
- disableRender() : mixed
- Disables rendering so child classes can change data or the template before output. Unifies the interface with KaController.
- enableRender() : mixed
- Enables rendering again. Unifies the interface with KaController.
- getRenderData() : array<string|int, mixed>
- Returns the template data merged with the temporary view data from the loader.
- getRenderTemplate() : string
- Returns the temporary view route from the loader.
- getTopMessages() : array<string|int, mixed>|null
- Returns top page messages from the session.
- loadAdminPageBlocks() : mixed
- Loads admin page blocks (header, left column, footer) and user_token into the data.
- loadCustomerPageBlocks() : mixed
- Loads storefront page blocks (header, footer, columns, content top and bottom) into the data.
- render() : string
- Renders the template with data and page blocks (children or the standard header, footer and columns). Returns an empty string when rendering is disabled. Example:
- showPage() : mixed
- Renders the page and sets it as the response output. Sets heading_title and page_id when missing and adds Ka Extensions CSS and JS.
Properties
$children
protected
mixed
$children
= array()
$data
protected
mixed
$data
= array()
$is_render_disabled
protected
mixed
$is_render_disabled
= false
$lastError
protected
mixed
$lastError
$template
protected
mixed
$template
= ''
Methods
getLastError()
Returns the last error.
public
getLastError() : mixed
Return values
mixed —Last error.
addTopMessage()
Adds a message shown at the top of the page; stored in the session.
protected
addTopMessage(mixed $msg[, mixed $type = 'S' ]) : mixed
$msg — message text or array of texts. $type — message type, 'S' by default.
Parameters
- $msg : mixed
- $type : mixed = 'S'
disableRender()
Disables rendering so child classes can change data or the template before output. Unifies the interface with KaController.
protected
disableRender() : mixed
enableRender()
Enables rendering again. Unifies the interface with KaController.
protected
enableRender() : mixed
getRenderData()
Returns the template data merged with the temporary view data from the loader.
protected
getRenderData() : array<string|int, mixed>
Return values
array<string|int, mixed> —Template data.
getRenderTemplate()
Returns the temporary view route from the loader.
protected
getRenderTemplate() : string
Return values
string —Template route.
getTopMessages()
Returns top page messages from the session.
protected
getTopMessages([mixed $clear = true ]) : array<string|int, mixed>|null
$clear — remove messages from the session.
Parameters
- $clear : mixed = true
Return values
array<string|int, mixed>|null —Messages or null.
loadAdminPageBlocks()
Loads admin page blocks (header, left column, footer) and user_token into the data.
protected
loadAdminPageBlocks() : mixed
loadCustomerPageBlocks()
Loads storefront page blocks (header, footer, columns, content top and bottom) into the data.
protected
loadCustomerPageBlocks() : mixed
render()
Renders the template with data and page blocks (children or the standard header, footer and columns). Returns an empty string when rendering is disabled. Example:
protected
render([mixed $tpl = '' ][, mixed $data = array() ]) : string
public function index() { $this->disableRender(); parent::index(); $this->enableRender(); $this->response->setOutput($this->render()); }
$tpl — template name. $data — template variables merged with existing data.
Parameters
- $tpl : mixed = ''
- $data : mixed = array()
Return values
string —Rendered page.
showPage()
Renders the page and sets it as the response output. Sets heading_title and page_id when missing and adds Ka Extensions CSS and JS.
protected
showPage([mixed $template = '' ][, mixed $data = array() ]) : mixed
$template — template name inside the module directory. $data — template variables; replace existing data.
Parameters
- $template : mixed = ''
- $data : mixed = array()