class Module implements Serializable (View source)

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

__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 insalled 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 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.

serialize()

unserialize($serialized)

Parameters

$serialized

activate()

Activate _config.php for this module, if one exists

ModuleResource getResource(string $path)

Get resource for this module

Parameters

string $path

Return Value

ModuleResource

string getRelativeResourcePath(string $path) deprecated

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

Parameters

string $path

Return Value

string

string getResourcePath(string $path) deprecated

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

Parameters

string $path

Return Value

string

string getResourceURL(string $path) deprecated

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

Parameters

string $path

Return Value

string

string hasResource(string $path) deprecated

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

Parameters

string $path

Return Value

string