• PHP reference
  • Models

Module

class Module

Module model.

Properties

integer $id

object $data

array|object $settings

string $version

string $namespace

string $icon

string $path

string $source

string $name

string $display_name

string $description

int $price

string $price_structure

string $scope

object $controllers

object $manifest

string $summary

int $time_updated

Methods

__construct($id, null $errorobj = null)

Module constructor.

Parameters

  • $id
  • null $errorobj

static boolean|object readManifest(string $path)

Read a module manifest at a specific module root path.

Parameters

  • string $path

Return Value

  • boolean|object

static boolean|string import(string $path, string|integer $source, boolean $icon_trigger = false)

Imports information from the module, and stores it in the database.

Parameters

  • string $path
  • string|integer $source
  • boolean $icon_trigger

Return Value

  • boolean|string

mixed __get($key)

Magic method __get.

Parameters

  • $key

Return Value

  • mixed

false|string icon()

Get the module icon URL.

Return Value

  • false|string

string summary()

Get the module summary description.

Return Value

  • string

Module[] get_dependencies()

Get all required dependencies for this module.

Return Value

boolean has_dependency(Module $mod)

Check if the module is dependent on another module.

Parameters

Return Value

  • boolean

boolean hasController(string $controller)

Check if module has a controller by name.

Parameters

  • string $controller

Return Value

  • boolean

boolean|string get_path(null $controller = null)

Get the absolute path to a certain controller of the current module.

Parameters

  • null $controller

Return Value

  • boolean|string

string getFilePath(string $filename)

Get absolute path for a file that is part of the module.

Parameters

  • string $filename

Return Value

  • string

string getStaticResource($filename, boolean $inline = false)

Get a static resource either by content or as an inline JS/CSS tag.

Parameters

  • $filename
  • boolean $inline

Return Value

  • string

Exceptions

boolean|mixed|string get_manifest(boolean|true $can_use_cache = true)

Get a module manifest from cache, db, or file.

Parameters

  • boolean|true $can_use_cache

Return Value

  • boolean|mixed|string

object|boolean get_controllers()

Retrieve an object containing all the module's controllers.

Return Value

  • object|boolean

array get_settings(integer $community = null, boolean $force = false)

Get all settings for a particular community and module.

Parameters

  • integer $community
  • boolean $force

Return Value

  • array

boolean|null|string setting(string $key, integer $community, boolean $force = false)

Retrieve a module setting for a particular community.

Parameters

  • string $key
  • integer $community
  • boolean $force

Return Value

  • boolean|null|string

boolean|string evaluate(string $controller, boolean|false $cron = false, Community $community = null, User $user = null)

Run a Module controller without a user context (but with an optional community context) and return the result to the caller.

Parameters

  • string $controller
  • boolean|false $cron
  • Community $community
  • User $user

Return Value

  • boolean|string

boolean|mixed|string evaluatePath(string $path, boolean $cron = false, Community $community = null, User $user = null)

Run a Module file and return the result to the caller.

Parameters

Return Value

  • boolean|mixed|string

string getNamespace($community)

Get the namespace for a certain module in a community context.

Parameters

  • $community

Return Value

  • string

mixed run(Community $community, array $imports = [], boolean $cron = false)

Run module within a certain community context.

Parameters

  • Community $community Community model
  • array $imports Settings that should be transferred
  • boolean $cron

Return Value

  • mixed

Exceptions

serveStatic(string $path, string $content_type = 'application/octet-stream')

Serve a static asset from a specific path in the module directory.

Parameters

  • string $path
  • string $content_type

installDependencies(Community $community)

Install dependencies for current module in a certain community.

Parameters

Exceptions