RdbAdmin Module

Modules
in package

Modules class.

Tags
since
0.1

Table of Contents

Properties

$Container  : Container
$currentModule  : string
$modules  : array<string|int, mixed>

Methods

__construct()  : mixed
Modules class constructor.
copyComposer()  : bool
Copy moduleComposer.json to main application composer.json.
copyComposerAllModules()  : array<string|int, mixed>
Copy moduleComposer.json from all modules into main app's composer.json
enable()  : bool
Set module to be disabled or enabled depend on `$enable` argument.
execute()  : string
Execute a module controller/method.
exists()  : bool
Check if module exists.
getCurrentModule()  : string
Get current module.
getModules()  : array<string|int, mixed>
Get list of modules.
getModuleSystemName()  : string
Get module system name (module folder name) from full path to such as module folder or any file in that module.
registerAutoload()  : mixed
Register auto load for modules that is not disabled.
setCurrentModule()  : mixed
Set current module from specific controller.
copyComposerPackageIfNewer()  : object
Copy composer package from module to root if module is using newer version range.

Properties

$currentModule

protected string $currentModule = ''

The current module, detected from setCurrentModule() method.

$modules

protected array<string|int, mixed> $modules = []

The module system name (folder name) that was registered to auto load and also enabled.

Methods

__construct()

Modules class constructor.

public __construct(Container $Container) : mixed

You can load this class via framework's Container object named Modules. Example: $Modules = $Container->get('Modules');.

Parameters
$Container : Container

The DI container class.

copyComposer()

Copy moduleComposer.json to main application composer.json.

public copyComposer(string $moduleSystemName) : bool
Parameters
$moduleSystemName : string

The module system name (folder name).

Return values
bool

Return true on success, false on failure.

copyComposerAllModules()

Copy moduleComposer.json from all modules into main app's composer.json

public copyComposerAllModules([bool $enabledOnly = true ]) : array<string|int, mixed>
Parameters
$enabledOnly : bool = true

Set to true to strict to enabled modules only, false for any modules existing.

Return values
array<string|int, mixed>

Return associative array with modulesWithComposer key as total modules that has moduleComposer.json, successCopied key as total success copied moduleComposer.json, failedModules key as list of failed module that unable to copy moduleComposer.json

enable()

Set module to be disabled or enabled depend on `$enable` argument.

public enable(string $moduleSystemName[, bool $enable = true ]) : bool
Parameters
$moduleSystemName : string

The module system name (folder name) to enable or disable.

$enable : bool = true

Set to true (default) to enable the module, set to false to disable it.

Tags
since
1.1.6
Return values
bool

Return true on success, false on failure.

execute()

Execute a module controller/method.

public execute(string $controllerMethod[, array<string|int, mixed> $args = [] ]) : string

This is useful for widgetize, modular process.

To check that is this a module execute, use $_SERVER['RUNDIZBONES_MODULEEXECUTE'].
Example:

if (!isset($_SERVER['RUNDIZBONES_MODULEEXECUTE']) || (isset($_SERVER['RUNDIZBONES_MODULEEXECUTE']) && $_SERVER['RUNDIZBONES_MODULEEXECUTE'] !== 'true')) {
    // this is NOT module execute.
} else {
    // this is module execute.
}

Before call this method:
Make sure that the module you specified is enabled otherwise the autoload will not working.

Parameters
$controllerMethod : string

The module's controller:method. The class name and its method should not has suffix. Example: Rdb\Modules\MyModule\Controllers\MyPage:index will be automatically converted to Rdb\Modules\MyModule\Controllers\MyPageController:indexAction.

$args : array<string|int, mixed> = []

The arguments of controller's method.

Tags
throws
InvalidArgumentException

Throw invalid argument exception if controller:method format is invalid.

Return values
string

Return response content of controller:method.

exists()

Check if module exists.

public exists(string $moduleSystemName[, bool $enabledOnly = true ]) : bool
Parameters
$moduleSystemName : string

The module system name (folder name).

$enabledOnly : bool = true

Set to true to check for enabled module only. Set to false to check for existing but don't care that it is enabled or not.

Return values
bool

Return true if exists, false for not exists.

getCurrentModule()

Get current module.

public getCurrentModule() : string

To use this, you must call to setCurrentModule() method before.

Return values
string

Return the current module.

getModules()

Get list of modules.

public getModules([bool $enabledOnly = true ]) : array<string|int, mixed>

To get all modules after called to registerAutoload() method.

Parameters
$enabledOnly : bool = true

Set to true (default) to get only enabled modules, set to false to get all.

Return values
array<string|int, mixed>

Return modules system name in array.

getModuleSystemName()

Get module system name (module folder name) from full path to such as module folder or any file in that module.

public getModuleSystemName(string $path) : string
Parameters
$path : string

Full path to module folder or file in that module.

Return values
string

Return just module system name if found that full path is in module folder. If full path is not in module folder then it will return SystemCore.

registerAutoload()

Register auto load for modules that is not disabled.

public registerAutoload() : mixed

This class was called at very first from \Rdb\System\App class. So, it has nothing like $Profiler to access.

setCurrentModule()

Set current module from specific controller.

public setCurrentModule(string $controller) : mixed
Parameters
$controller : string

The controller class to check. To detect controller class, use get_called_class() function in the controller.

copyComposerPackageIfNewer()

Copy composer package from module to root if module is using newer version range.

private copyComposerPackageIfNewer(object $RootComposerObject, object $ModuleComposerObject[, string $copyProperty = 'require' ]) : object

This method was called from copyComposer().

Parameters
$RootComposerObject : object
$ModuleComposerObject : object
$copyProperty : string = 'require'

The property on moduleComposer.json that will be copy. Accept 'require', 'require-dev'.

Tags
since
1.1.4
Return values
object

Return modified root composer object.


        
On this page

Search results