class Module implements Serializable

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

Constants

TRIM_CHARS

Methods

__construct(string $path, string $basePath)

Construct a module

string
getName()

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

string|null
getComposerName()

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

array
getExposedFolders()

Get list of folders that need to be made available

string
getShortName()

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

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 will be returned if the key is undefined.

string
getPath()

Get base path for this module

string
getRelativePath()

Get path relative to base dir.

serialize()

No description

unserialize($serialized)

No description

activate()

Activate _config.php for this module, if one exists

getResource(string $path)

Get resource for this module

string
getRelativeResourcePath(string $path) deprecated

No description

string
getResourcePath(string $path) deprecated

No description

string
getResourceURL(string $path) deprecated

No description

string
hasResource(string $path) deprecated

No description

Details

at line 56
__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

at line 71
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 insalled by composer this will default to the basedir()

Return Value

string

at line 81
string|null getComposerName()

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

Return Value

string|null

at line 94
array getExposedFolders()

Get list of folders that need to be made available

Return Value

array

at line 110
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

at line 138
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 will be returned if the key is undefined.

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

Return Value

string

at line 150
string getPath()

Get base path for this module

Return Value

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

at line 161
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.

at line 169
serialize()

at line 174
unserialize($serialized)

Parameters

$serialized

at line 183
activate()

Activate _config.php for this module, if one exists

at line 215
ModuleResource getResource(string $path)

Get resource for this module

Parameters

string $path

Return Value

ModuleResource

at line 232
string getRelativeResourcePath(string $path) deprecated

deprecated 4.0.0:5.0.0 Use getResource($path)->getRelativePath() instead

Parameters

string $path

Return Value

string

at line 245
string getResourcePath(string $path) deprecated

deprecated 4.0.0:5.0.0 Use ->getResource($path)->getPath() instead

Parameters

string $path

Return Value

string

at line 258
string getResourceURL(string $path) deprecated

deprecated 4.0.0:5.0.0 Use ->getResource($path)->getURL() instead

Parameters

string $path

Return Value

string

at line 271
string hasResource(string $path) deprecated

deprecated 4.0.0:5.0.0 Use ->getResource($path)->exists() instead

Parameters

string $path

Return Value

string