ModuleHelper
in package
Uses
SortByVersionTrait
Table of Contents
- $composerHelper : ComposerHelper
- $db : ADOConnection
- $directories : array<string|int, mixed>
- $installedVersionMapper : InstalledVersionMapper
- $listClassesInDirectory : ListClassesInDirectory
- $logger : MonologWrapper
- $processorHelper : ProcessorHelper
- $settings : Config
- __construct() : mixed
- getInstalled() : array<string|int, mixed>
- Return an array of installed modules and their current version.
- getModules() : array<string|int, mixed>
- Return a list of all non-core modules and plugins in the codebase.
- getUninstalled() : array<string|int, mixed>
- Return an array of uninstalled non-core modules and plugins.
- install() : array<string|int, mixed>
- Install one or more modules.
- sortByVersion() : int
- Custom sort function to sort array of version string.
- uninstall() : array<string|int, mixed>
- Uninstall one or more modules.
- update() : array<string|int, mixed>
- Run updates for a module or plugin.
- updates() : array<string|int, mixed>
- Return modules details for all modules that require updates.
- functionExistsInFile() : bool
- Validate if a function definition exists in a file.
- getAllUpdateFunctions() : array<string|int, mixed>
- Return a sorted array of all update functions in a file.
- getDetails() : array<string|int, mixed>|false
- Return the default details attributed from a class, and its full filepath.
- getInstalledVersion() : false|InstalledVersion
- Return false if a module or processor has not been installed, or its installed_version.
- getUpdateFunctions() : array<string|int, mixed>
- Get list of update functions that need to be run for a module.
Properties
$composerHelper
protected
ComposerHelper
$composerHelper
$db
protected
ADOConnection
$db
$directories
protected
array<string|int, mixed>
$directories
= ['Endpoint', 'Output', 'Processor', 'Security']
List of directories containing plugins and modules.
$installedVersionMapper
protected
InstalledVersionMapper
$installedVersionMapper
$listClassesInDirectory
protected
ListClassesInDirectory
$listClassesInDirectory
$logger
protected
MonologWrapper
$logger
$processorHelper
protected
ProcessorHelper
$processorHelper
$settings
protected
Config
$settings
Methods
__construct()
public
__construct([ADOConnection|null $db = null ]) : mixed
Parameters
- $db : ADOConnection|null = null
Tags
Return values
mixed —getInstalled()
Return an array of installed modules and their current version.
public
getInstalled() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getModules()
Return a list of all non-core modules and plugins in the codebase.
public
getModules([bool $includeCore = false ]) : array<string|int, mixed>
Parameters
- $includeCore : bool = false
Tags
Return values
array<string|int, mixed> —getUninstalled()
Return an array of uninstalled non-core modules and plugins.
public
getUninstalled() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —install()
Install one or more modules.
public
install(array<string|int, mixed> $modules) : array<string|int, mixed>
Parameters
- $modules : array<string|int, mixed>
-
Array of machine_names.
Tags
Return values
array<string|int, mixed> —sortByVersion()
Custom sort function to sort array of version string.
public
sortByVersion(string $a, string $b) : int
This assumes example version format of: 1.2.0 1.2.1 1.2.2 1.2.3-alpha 1.2.3-alpha1 1.2.3-alpha2 1.2.3-beta 1.2.3-beta1 1.2.3-beta2 1.2.3-rc 1.2.3-rc1 1.2.3-rc2 1.2.3 1.3.0
Parameters
- $a : string
- $b : string
Return values
int —uninstall()
Uninstall one or more modules.
public
uninstall(array<string|int, mixed> $modules) : array<string|int, mixed>
Parameters
- $modules : array<string|int, mixed>
-
Array of machine_names.
Tags
Return values
array<string|int, mixed> —update()
Run updates for a module or plugin.
public
update(array<string|int, mixed> $modules) : array<string|int, mixed>
Parameters
- $modules : array<string|int, mixed>
-
Array of machine_names.
Tags
Return values
array<string|int, mixed> —updates()
Return modules details for all modules that require updates.
public
updates([array<string|int, mixed> $modules = [] ]) : array<string|int, mixed>
Parameters
- $modules : array<string|int, mixed> = []
Tags
Return values
array<string|int, mixed> —functionExistsInFile()
Validate if a function definition exists in a file.
protected
functionExistsInFile(string $filePath, string $functionName) : bool
Parameters
- $filePath : string
-
Full filepath.
- $functionName : string
-
Function name.
Return values
bool —getAllUpdateFunctions()
Return a sorted array of all update functions in a file.
protected
getAllUpdateFunctions(string $filePath, string $className) : array<string|int, mixed>
The Array is sorted by version string. All functions should have the same namespace as the module.
Parameters
- $filePath : string
-
Absolute oath to the update file.
- $className : string
-
Namespaced classname for the module.
Tags
Return values
array<string|int, mixed> —getDetails()
Return the default details attributed from a class, and its full filepath.
protected
getDetails(string $className) : array<string|int, mixed>|false
Parameters
- $className : string
-
The classname.
Tags
Return values
array<string|int, mixed>|false —getInstalledVersion()
Return false if a module or processor has not been installed, or its installed_version.
protected
getInstalledVersion(string $module) : false|InstalledVersion
Parameters
- $module : string
-
Module machine_name.
Tags
Return values
false|InstalledVersion —getUpdateFunctions()
Get list of update functions that need to be run for a module.
protected
getUpdateFunctions(string $filePath, string $className) : array<string|int, mixed>
Parameters
- $filePath : string
- $className : string