Class humhub\components\ModuleManager

Inheritancehumhub\components\ModuleManager » yii\base\Component

ModuleManager handles all installed modules.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$createBackup boolean humhub\components\ModuleManager

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$coreModules array The core module class names humhub\components\ModuleManager
$enabledModules array humhub\components\ModuleManager
$modules List of all modules This also contains installed but not enabled modules. humhub\components\ModuleManager

Public Methods

Hide inherited methods

MethodDescriptionDefined By
canRemoveModule() Checks the module can removed humhub\components\ModuleManager
disable() Disables a module humhub\components\ModuleManager
disableModules() humhub\components\ModuleManager
enable() Enables a module humhub\components\ModuleManager
enableModules() humhub\components\ModuleManager
flushCache() Flushes module manager cache humhub\components\ModuleManager
getEnabledModules() Returns all enabled modules and supportes further options as getModules(). humhub\components\ModuleManager
getModule() Returns a module instance by id humhub\components\ModuleManager
getModules() Returns all modules (also disabled modules). humhub\components\ModuleManager
hasModule() Checks if a moduleId exists, regardless it's activated or not humhub\components\ModuleManager
init() Module Manager init humhub\components\ModuleManager
isCoreModule() Returns weather or not the given module id belongs to an core module. humhub\components\ModuleManager
register() Registers a module humhub\components\ModuleManager
registerBulk() Registers a module to the manager This is usually done by config.php in modules root folder. humhub\components\ModuleManager
removeModule() Removes a module humhub\components\ModuleManager

Events

Hide inherited events

EventTypeDescriptionDefined By
EVENT_AFTER_MODULE_DISABLE \humhub\components\triggered After a module is disabled humhub\components\ModuleManager
EVENT_AFTER_MODULE_ENABLE \humhub\components\triggered After a module is enabled humhub\components\ModuleManager
EVENT_BEFORE_MODULE_DISABLE \humhub\components\triggered Before a module is disabled humhub\components\ModuleManager
EVENT_BEFORE_MODULE_ENABLE \humhub\components\triggered Before a module is enabled humhub\components\ModuleManager

Property Details

$coreModules protected property

The core module class names

protected array $coreModules = []
$createBackup public property
public boolean $createBackup true
$enabledModules protected property
protected array $enabledModules = []
$modules protected property
protected $modules null

Method Details

canRemoveModule() public method

Checks the module can removed

public boolean canRemoveModule ( $moduleId )
$moduleId string
disable() public method (available since version 1.1)

Disables a module

public void disable ( humhub\components\Module $module )
$module humhub\components\Module
disableModules() public method

public void disableModules ( $modules = [] )
$modules
enable() public method (available since version 1.1)

Enables a module

public void enable ( humhub\components\Module $module )
$module humhub\components\Module
enableModules() public method

public void enableModules ( $modules = [] )
$modules
flushCache() public method

Flushes module manager cache

public void flushCache ( )
getEnabledModules() public method (available since version 1.3.10)

Returns all enabled modules and supportes further options as getModules().

public array getEnabledModules ( $options = [] )
$options array
throws \yii\base\Exception
getModule() public method

Returns a module instance by id

public humhub\components\Module|object getModule ( $id )
$id string

Module Id

getModules() public method

Returns all modules (also disabled modules).

Note: Only modules which extends \humhub\components\Module will be returned.

public array getModules ( $options = [] )
$options array

Options (name => config) The following options are available:

  • includeCoreModules: boolean, return also core modules (default: false)
  • returnClass: boolean, return classname instead of module object (default: false)
  • enabled: boolean, returns only enabled modules (core modules only when combined with includeCoreModules)
throws \yii\base\Exception
hasModule() public method

Checks if a moduleId exists, regardless it's activated or not

public boolean hasModule ( $id )
$id string
init() public method

Module Manager init

Loads all enabled moduleId's from database

public void init ( )
isCoreModule() public method (available since version 1.3.8)

Returns weather or not the given module id belongs to an core module.

public boolean isCoreModule ( $id )
$id
throws \yii\base\Exception
register() public method

Registers a module

public void register ( $basePath, $config null )
$basePath string

The modules base path

$config array

The module configuration (config.php)

throws \yii\base\InvalidConfigException
registerBulk() public method

Registers a module to the manager This is usually done by config.php in modules root folder.

See also humhub\components\bootstrap\ModuleAutoLoader::bootstrap().

public void registerBulk ( array $configs )
$configs array
throws \yii\base\InvalidConfigException
removeModule() public method

Removes a module

public void removeModule ( $moduleId, $disableBeforeRemove true )
$moduleId string
$disableBeforeRemove boolean
throws \yii\base\Exception
throws \yii\base\ErrorException

Event Details

EVENT_AFTER_MODULE_DISABLE event of type \humhub\components\triggered

After a module is disabled

EVENT_AFTER_MODULE_ENABLE event of type \humhub\components\triggered

After a module is enabled

EVENT_BEFORE_MODULE_DISABLE event of type \humhub\components\triggered

Before a module is disabled

EVENT_BEFORE_MODULE_ENABLE event of type \humhub\components\triggered

Before a module is enabled