ControllerInstaller
extends Controller
in component
This class contains essential parts of the module installation. It reads the extension manifest (install.json), checks compatibility with the Ka Extensions library and the database, creates tables and grants permissions to the extension pages. Module settings pages inherit from it through ControllerSettings.
Table of Contents
Properties
Methods
- __construct() : mixed
- Creates the controller, initializes the Ka database wrapper, adds the Ka Extensions stylesheet in the admin area and calls onLoad().
- getDocsLink() : string
- Returns the documentation link from the manifest.
- getExtLink() : string
- Returns the extension link from the manifest.
- getLastError() : mixed
- Returns the last error.
- getTitle() : string
- Returns the extension title with its version, e.g. 'My Module (ver.1.0.0.0)'.
- getVersion() : string
- Returns the extension version from the manifest.
- install() : bool
- Installs the extension: checks compatibility, patches the database by the tables definition and
grants permissions to the extension pages for the current user group. - uninstall() : bool
- Uninstalls the extension and revokes permissions to the extension pages from all user groups.
- addTopMessage() : mixed
- Adds a message shown at the top of the page; stored in the session.
- checkCompatibility() : bool
- Checks that the extension is compatible with the installed Ka Extensions library and the database.
- 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.
- getExtensionPages() : array<string|int, mixed>
- Returns a list of extension routes which should get access and modify permissions on extension
installation. The routes are relative to 'extension/<ext_code>/'. - 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.
- getSession() : mixed
- Returns a reference to a value in the session area of the current class; null is created if missing.
- 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.
- onLoad() : void
- Loads required models and the extension manifest (install.json) and fills in the extension
version, links and the minimum Ka Extensions version from it. - 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:
- setSession() : mixed
- Stores a value in the session area of the current class.
- 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
$ka_extensions_version
public
static mixed
$ka_extensions_version
= '5.1.1.1'
$children
protected
mixed
$children
= array()
$data
protected
mixed
$data
= array()
$docs_link
protected
mixed
$docs_link
= ''
$ext_code
protected
mixed
$ext_code
= ''
$ext_link
protected
mixed
$ext_link
= ''
$extension_version
protected
mixed
$extension_version
= '1.0.0.0'
$ini
protected
mixed
$ini
$is_render_disabled
protected
mixed
$is_render_disabled
= false
$kadb
protected
mixed
$kadb
= null
$kamodel_common
protected
mixed
$kamodel_common
$kamodel_patchdb
protected
mixed
$kamodel_patchdb
$lastError
protected
mixed
$lastError
$min_ka_extensions_version
protected
mixed
$min_ka_extensions_version
= '0.0.0.0'
$tables
protected
mixed
$tables
$template
protected
mixed
$template
= ''
Methods
__construct()
Creates the controller, initializes the Ka database wrapper, adds the Ka Extensions stylesheet in the admin area and calls onLoad().
public
__construct(mixed $registry) : mixed
$registry — OpenCart registry.
Parameters
- $registry : mixed
getDocsLink()
Returns the documentation link from the manifest.
public
getDocsLink() : string
Return values
stringgetExtLink()
Returns the extension link from the manifest.
public
getExtLink() : string
Return values
stringgetLastError()
Returns the last error.
public
getLastError() : mixed
Return values
mixed —Last error.
getTitle()
Returns the extension title with its version, e.g. 'My Module (ver.1.0.0.0)'.
public
getTitle() : string
Return values
stringgetVersion()
Returns the extension version from the manifest.
public
getVersion() : string
Return values
stringinstall()
Installs the extension: checks compatibility, patches the database by the tables definition and grants permissions to the extension pages for the current user group.
public
install(mixed $params) : bool
$params — for now it is just a way to prevent calling this method from url. Later the extension manager can pass some information through this array.
Parameters
- $params : mixed
Return values
bool —True on success.
uninstall()
Uninstalls the extension and revokes permissions to the extension pages from all user groups.
public
uninstall(mixed $params) : bool
$params — for now it is just a way to prevent calling this method from url. Later the extension manager can pass some information through this array.
Parameters
- $params : mixed
Return values
booladdTopMessage()
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'
checkCompatibility()
Checks that the extension is compatible with the installed Ka Extensions library and the database.
protected
checkCompatibility(mixed &$tables, mixed &$messages) : bool
$tables — tables definition to check. $messages — receives error messages.
Parameters
- $tables : mixed
- $messages : mixed
Return values
bool —True if the extension is compatible.
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
getExtensionPages()
Returns a list of extension routes which should get access and modify permissions on extension installation. The routes are relative to 'extension/<ext_code>/'.
protected
getExtensionPages() : array<string|int, mixed>
Return values
array<string|int, 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.
getSession()
Returns a reference to a value in the session area of the current class; null is created if missing.
protected
& getSession(mixed $key) : mixed
$key — value key.
Parameters
- $key : mixed
Return values
mixed —Reference to the value.
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
onLoad()
Loads required models and the extension manifest (install.json) and fills in the extension version, links and the minimum Ka Extensions version from it.
protected
onLoad() : void
Tags
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.
setSession()
Stores a value in the session area of the current class.
protected
setSession(mixed $key, mixed $value) : mixed
$key — value key. $value — value.
Parameters
- $key : mixed
- $value : mixed
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()