Class humhub\modules\content\components\ContentContainerModule

Inheritancehumhub\modules\content\components\ContentContainerModule » humhub\components\Module » yii\base\Module
Available since version0.20

Base Module with ContentContainer support.

Override this class if your module should have the possibility to be enabled/disabled on a content container (e.g. Space/User).

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$resourcesPath string The path for module resources (images, javascripts) Also module related assets like README. humhub\components\Module

Public Methods

Hide inherited methods

MethodDescriptionDefined By
disable() Disables a module humhub\modules\content\components\ContentContainerModule
disableContentContainer() Disables module on given content container Override this method to cleanup created data in content container context. humhub\modules\content\components\ContentContainerModule
enable() Enables this module humhub\components\Module
enableContentContainer() Enables this module on the given content container Override this method e.g. to set default settings. humhub\modules\content\components\ContentContainerModule
getActivityClasses() Returns a list of activity class names this modules provides. humhub\components\Module
getAssetClasses() Returns a list of asset class names this modules provides. humhub\components\Module
getAssetPath() humhub\components\Module
getAssetsUrl() Get Assets Url humhub\components\Module
getConfigUrl() URL to the module's configuration action humhub\components\Module
getContentContainerConfigUrl() Returns the url to configure this module in a content container humhub\modules\content\components\ContentContainerModule
getContentContainerDescription() Returns the module description shown in content container modules section. humhub\modules\content\components\ContentContainerModule
getContentContainerImage() Returns the url to the module image shown in content containers module section. humhub\modules\content\components\ContentContainerModule
getContentContainerName() Returns the name of the module used in content container context. humhub\modules\content\components\ContentContainerModule
getContentContainerTypes() Returns the list of valid content container classes this module supports. humhub\modules\content\components\ContentContainerModule
getDescription() Returns modules description provided by module.json file humhub\components\Module
getEnabledContentContainers() Returns an array of all content containers where this module is enabled. humhub\modules\content\components\ContentContainerModule
getImage() Returns image url for this module Place your modules image in /module_image.png humhub\components\Module
getName() Returns modules name provided by module.json file humhub\components\Module
getNotifications() Returns a list of notification classes this module provides. humhub\components\Module
getPermissions() This function enhances the default humhub\components\Module::getPermissions() behaviour by automatically checking the installation state of this module on the provided humhub\modules\content\components\ContentContainerActiveRecord. humhub\modules\content\components\ContentContainerModule
getPublishedUrl() Returns the url of an asset file and publishes all module assets if the file is not published yet. humhub\components\Module
getVersion() Returns modules version number provided by module.json file humhub\components\Module
hasContentContainerType() Checks whether the module is enabled the given content container class. humhub\modules\content\components\ContentContainerModule
hasNotifications() Determines whether the module has notification classes or not humhub\components\Module
init() humhub\components\Module
isPublished() Checks if a specific asset file has already been published humhub\components\Module
migrate() Execute all not applied module migrations humhub\components\Module
publishAssets() Publishes the basePath/resourcesPath (assets) module directory if existing. humhub\components\Module
update() This method is called after an update is performed. humhub\components\Module

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
getContainerPermissions() This method is called to determine available permissions only for containers this module is enabled on. humhub\modules\content\components\ContentContainerModule
getGlobalPermissions() This method is called to determine only global (no container related) permissions of this module. humhub\modules\content\components\ContentContainerModule
getModuleInfo() Reads module.json which contains basic module information and returns it as array humhub\components\Module

Method Details

disable() public method

Disables a module

This should delete all data created by this module. When override this method make sure to invoke call parent::disable() AFTER your implementation as

public function disable()
{
    // custom disable logic
    parent::disable();
}
public void disable ( )
disableContentContainer() public method

Disables module on given content container Override this method to cleanup created data in content container context.

public function disableContentContainer(ContentContainerActiveRecord $container)
{
     parent::disableContentContainer($container);
     foreach (MyContent::find()->contentContainer($container)->all() as $content) {
         $content->delete();
     }
}
public void disableContentContainer ( humhub\modules\content\components\ContentContainerActiveRecord $container )
$container humhub\modules\content\components\ContentContainerActiveRecord

The content container

enableContentContainer() public method

Enables this module on the given content container Override this method e.g. to set default settings.

public void enableContentContainer ( humhub\modules\content\components\ContentContainerActiveRecord $container )
$container humhub\modules\content\components\ContentContainerActiveRecord
getContainerPermissions() protected method (available since version 1.3.11)

This method is called to determine available permissions only for containers this module is enabled on.

See also humhub\modules\content\components\ContentContainerModule::getPermissions().

protected array getContainerPermissions ( $contentContainer null )
$contentContainer null
getContentContainerConfigUrl() public method

Returns the url to configure this module in a content container

public string getContentContainerConfigUrl ( humhub\modules\content\components\ContentContainerActiveRecord $container )
$container humhub\modules\content\components\ContentContainerActiveRecord
return string

The config url

getContentContainerDescription() public method

Returns the module description shown in content container modules section.

By default the main module description is returned.

public string getContentContainerDescription ( humhub\modules\content\components\ContentContainerActiveRecord $container )
$container string
return string

The module description

getContentContainerImage() public method

Returns the url to the module image shown in content containers module section.

By default the main module image url is returned.

public string getContentContainerImage ( humhub\modules\content\components\ContentContainerActiveRecord $container )
$container humhub\modules\content\components\ContentContainerActiveRecord
return string

The url to the image

getContentContainerName() public method

Returns the name of the module used in content container context.

By default the main module name is returned.

public string getContentContainerName ( humhub\modules\content\components\ContentContainerActiveRecord $container )
$container humhub\modules\content\components\ContentContainerActiveRecord
return string

The module name

getContentContainerTypes() public method

Returns the list of valid content container classes this module supports.

public function getContentContainerTypes()
{
     return [
         User::className(),
         Space::className()
     ];
}
public array getContentContainerTypes ( )
return array

Valid content container classes

getEnabledContentContainers() public method

Returns an array of all content containers where this module is enabled.

public array getEnabledContentContainers ( $containerClass "" )
$containerClass string

Optional filter to specific container class

return array

Of content container instances

getGlobalPermissions() protected method (available since version 1.3.11)

This method is called to determine only global (no container related) permissions of this module.

See also humhub\modules\content\components\ContentContainerModule::getPermissions().

protected array getGlobalPermissions ( )
getPermissions() public method (available since version 1.3.11)

This function enhances the default humhub\components\Module::getPermissions() behaviour by automatically checking the installation state of this module on the provided humhub\modules\content\components\ContentContainerActiveRecord.

In case a container object was provided which this module is installed on we forward the call to getContainerPermissions(). If a container is given which this module is not installed on we return an empty array. If no container was provided we forward the call to getGlobalPermissions().

Sub classes should overwrite getContainerPermissions() and/or getGlobalPermissions() unless a special permission behaviour is required.

See also humhub\components\Module::getPermissions().

public array getPermissions ( $contentContainer null )
$contentContainer humhub\modules\content\components\ContentContainerActiveRecord
hasContentContainerType() public method

Checks whether the module is enabled the given content container class.

public boolean hasContentContainerType ( $class )
$class string

The class of content container