class Module (View source)

Abstraction of a PHP Package. Can be used to retrieve information about Silverstripe CMS modules, and other packages managed via composer, by reading their composer.json file.

Properties

protected string $path

Full directory path to this module with no trailing slash

protected string $basePath

Base folder of application with no trailing slash

protected array $composerData

Cache of composer data

protected ModuleResource[] $resources

Loaded resources for this module

Methods

public
__construct(string $path, string $basePath)

Construct a module

public
string
getName()

Gets name of this module. Used as unique key and identifier for this module.

public
string|null
getComposerName()

Get full composer name. Will be null if no composer.json is available

public
array
getExposedFolders()

Get list of folders that need to be made available

public
string
getShortName()

Gets "short" name of this module. This is the base directory this module is installed in.

public
string
getResourcesDir()

Name of the resource directory where vendor resources should be exposed as defined by the extra.resources-dir key in the composer file. A blank string will be returned if the key is undefined.

public
string
getPath()

Get base path for this module

public
string
getRelativePath()

Get path relative to base dir.

public
array
__serialize()

No description

public
void
__unserialize(array $data)

No description

public
activate()

Activate _config.php for this module, if one exists

protected
loadComposer()

No description

public
getResource(string $path)

Get resource for this module

Details

__construct(string $path, string $basePath)

Construct a module

Parameters

string $path

Absolute filesystem path to this module

string $basePath

base path for the application this module is installed in

string getName()

Gets name of this module. Used as unique key and identifier for this module.

If installed by composer, this will be the full composer name (vendor/name). If not installed by composer this will default to the basedir()

Return Value

string

string|null getComposerName()

Get full composer name. Will be null if no composer.json is available

Return Value

string|null

array getExposedFolders()

Get list of folders that need to be made available

Return Value

array

string getShortName()

Gets "short" name of this module. This is the base directory this module is installed in.

If installed in root, this will be generated from the composer name instead

Return Value

string

string getResourcesDir()

Name of the resource directory where vendor resources should be exposed as defined by the extra.resources-dir key in the composer file. A blank string will be returned if the key is undefined.

Only applicable when reading the composer file for the main project.

Return Value

string

string getPath()

Get base path for this module

Return Value

string

Path with no trailing slash E.g. /var/www/module

string getRelativePath()

Get path relative to base dir.

If module path is base this will be empty string

Return Value

string

Path with trimmed slashes. E.g. vendor/silverstripe/module.

array __serialize()

No description

Return Value

array

void __unserialize(array $data)

No description

Parameters

array $data

Return Value

void

activate()

Activate _config.php for this module, if one exists

protected loadComposer()

No description

Exceptions

Exception

ModuleResource getResource(string $path)

Get resource for this module

Parameters

string $path

Return Value

ModuleResource