class module implements tool_interface

Migration module management tool

Properties

protected driver_interface $db
protected user $user
protected module_manager $module_manager
protected string $modules_table
protected array $module_categories

Methods

__construct(driver_interface $db, user $user, module_manager $module_manager, string $modules_table)

Constructor

string
get_name()

Retrieve a short name used for commands in migrations.

bool
exists(string $class, int|string|bool $parent, int|string $module, bool $lazy = false)

Module Exists

null
add(string $class, int|string $parent = 0, array $data = array())

Module Add

null
remove(string $class, int|string|bool $parent = 0, int|string $module = '')

Module Remove

null
reverse()

Reverse an original install action

array
get_module_info(string $class, string $basename)

Wrapper for \acp_modules::get_module_infos()

null
get_categories_list()

Get the list of installed module categories key - module_id value - module_langname

mixed
get_parent_module_id(string|int $parent_id, int|string|array $data = '', bool $throw_exception = true)

Get parent module id

Details

at line 46
__construct(driver_interface $db, user $user, module_manager $module_manager, string $modules_table)

Constructor

Parameters

driver_interface $db
user $user
module_manager $module_manager
string $modules_table

at line 57
string get_name()

Retrieve a short name used for commands in migrations.

Return Value

string

short name

at line 77
bool exists(string $class, int|string|bool $parent, int|string $module, bool $lazy = false)

Module Exists

Check if a module exists

Parameters

string $class

The module class(acp|mcp|ucp)

int|string|bool $parent

The parent module_id|module_langname (0 for no parent). Use false to ignore the parent check and check class wide.

int|string $module

The module_id|module_langname you would like to check for to see if it exists

bool $lazy

Checks lazily if the module exists. Returns true if it exists in at least one given parent.

Return Value

bool

true if module exists in all given parents, false if not in any given parent; true if ignoring parent check and module exists class wide, false if not found at all.

at line 168
null add(string $class, int|string $parent = 0, array $data = array())

Module Add

Add a new module

Parameters

string $class

The module class(acp|mcp|ucp)

int|string $parent

The parent module_id|module_langname (0 for no parent)

array $data

an array of the data on the new \module. This can be setup in two different ways.

  1. The "manual" way. For inserting a category or one at a time. It will be merged with the base array shown a bit below, but at the least requires 'module_langname' to be sent, and, if you want to create a module (instead of just a category) you must send module_basename and module_mode. array( 'module_enabled' => 1, 'module_display' => 1, 'module_basename' => '', 'module_class' => $class, 'parent_id' => (int) $parent, 'module_langname' => '', 'module_mode' => '', 'module_auth' => '', )
  2. The "automatic" way. For inserting multiple at a time based on the specs in the info file for the module(s). For this to work the modules must be correctly setup in the info file. An example follows (this would insert the settings, log, and flag modes from the includes/acp/info/acp_asacp.php file): array( 'module_basename' => 'asacp', 'modes' => array('settings', 'log', 'flag'), ) Optionally you may not send 'modes' and it will insert all of the modules in that info file. path, specify that here

Return Value

null

Exceptions

exception

at line 345
null remove(string $class, int|string|bool $parent = 0, int|string $module = '')

Module Remove

Remove a module

Parameters

string $class

The module class(acp|mcp|ucp)

int|string|bool $parent

The parent module_id|module_langname(0 for no parent). Use false to ignore the parent check and check class wide.

int|string $module

The module id|module_langname specify that here

Return Value

null

Exceptions

exception

at line 420
null reverse()

Reverse an original install action

First argument is the original call to the class (e.g. add, remove) After the first argument, send the original arguments to the function in the original call

Return Value

null

at line 456
protected array get_module_info(string $class, string $basename)

Wrapper for \acp_modules::get_module_infos()

Parameters

string $class

Module Class

string $basename

Module Basename

Return Value

array

Module Information

Exceptions

exception

at line 475
protected null get_categories_list()

Get the list of installed module categories key - module_id value - module_langname

Return Value

null

at line 502
mixed get_parent_module_id(string|int $parent_id, int|string|array $data = '', bool $throw_exception = true)

Get parent module id

Parameters

string|int $parent_id

The parent module_id|module_langname

int|string|array $data

The module_id, module_langname for existence checking or module data array for adding

bool $throw_exception

The flag indicating if exception should be thrown on error

Return Value

mixed

The int parent module_id, an array of int parent module_id values or false

Exceptions

exception