phpBB API Documentation
Class

phpbb\db\migration\tool\module

class module implements tool_interface

Migration module management tool

Methods

__construct(driver_interface $db, service $cache, user $user, module_manager $module_manager, string $phpbb_root_path, string $php_ext, 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)

Module Exists

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

Module Add

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

Module Remove

null reverse()

Reverse an original install action

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

Get parent module id

Details

at line 58
public __construct(driver_interface $db, service $cache, user $user, module_manager $module_manager, string $phpbb_root_path, string $php_ext, string $modules_table)

Constructor

Parameters

driver_interface $db
service $cache
user $user
module_manager $module_manager
string $phpbb_root_path
string $php_ext
string $modules_table

at line 72
public string get_name()

Retrieve a short name used for commands in migrations.

Return Value

string short name

at line 89
public bool exists(string $class, int|string|bool $parent, int|string $module)

Module Exists

Check if a module exists

Parameters

string $class The module class(acp|mcp|ucp)
int|string|bool $parent The parent moduleid|modulelangname (0 for no parent). Use false to ignore the parent check and check class wide.
int|string $module The moduleid|modulelangname you would like to check for to see if it exists

Return Value

bool true/false if module exists

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

Module Add

Add a new module

Parameters

string $class The module class(acp|mcp|ucp)
int|string $parent The parent moduleid|modulelangname (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 'modulelangname' to be sent, and, if you want to create a module (instead of just a category) you must send modulebasename and modulemode. array( 'moduleenabled' => 1, 'moduledisplay' => 1, 'modulebasename' => '', 'moduleclass' => $class, 'parentid' => (int) $parent, 'modulelangname' => '', 'modulemode' => '', 'moduleauth' => '', ) 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/acpasacp.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 306
public null remove(string $class, int|string|bool $parent, int|string $module = '')

Module Remove

Remove a module

Parameters

string $class The module class(acp|mcp|ucp)
int|string|bool $parent The parent moduleid|modulelangname(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 381
public 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 463
public 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 moduleid|modulelangname
int|string|array $data The moduleid, modulelangname for existance 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 or false

Exceptions

exception