CRM_Extension_Manager
in package
The extension manager handles installing, disabling enabling, and uninstalling extensions.
You should obtain a singleton of this class via
$manager = CRM_Extension_System::singleton()->getManager();
Tags
Table of Contents
Constants
- STATUS_DISABLED = 'disabled'
- The extension config has been applied to database but deactivated.
- STATUS_DISABLED_MISSING = 'disabled-missing'
- The extension was installed and is now disabled; the code is not accessible
- STATUS_INSTALLED = 'installed'
- The extension is fully installed and enabled.
- STATUS_INSTALLED_MISSING = 'installed-missing'
- The extension is installed but the code is not accessible
- STATUS_UNINSTALLED = 'uninstalled'
- The extension code is visible, but nothing has been applied to DB
- STATUS_UNKNOWN = 'unknown'
- The extension code is not locally accessible
Properties
- $defaultContainer : CRM_Extension_Container_Basic|false
- Default container.
- $fullContainer : CRM_Extension_Container_Interface
- $mapper : CRM_Extension_Mapper
- Mapper.
- $statuses : array<string|int, mixed>
- Statuses.
- $typeManagers : array<string|int, mixed>
- Type managers.
- $processes : array<string|int, mixed>
- Live process(es) per extension.
Methods
- __construct() : mixed
- Class constructor.
- createInfoFromDB() : CRM_Extension_Info|null
- Auto-generate a place-holder for a missing extension using info from database.
- disable() : mixed
- Disable extension without removing record from db.
- enable() : mixed
- Add records of the extension to the database -- and enable it
- extensionIsBeingInstalledOrEnabled() : bool
- Determine if the extension specified is currently involved in an install or enable process. Just sugar code to make things more readable.
- findDisableRequirements() : array<string|int, mixed>
- Build a list of extensions to remove, in an order that will satisfy dependencies.
- findInstallRequirements() : array<string|int, mixed>
- Build a list of extensions to install, in an order that will satisfy dependencies.
- getActiveProcesses() : array<string|int, mixed>
- Return current processes for given extension.
- getStatus() : string
- Determine the status of an extension.
- getStatuses() : array<string|int, mixed>
- Determine the status of all extensions.
- install() : mixed
- Add records of the extension to the database -- and enable it
- isEnabled() : bool
- Check if a given extension is installed and enabled
- isIncompatible() : bool|array<string|int, mixed>
- Check if a given extension is incompatible with this version of CiviCRM
- refresh() : mixed
- replace() : mixed
- Install or upgrade the code for an extension -- and perform any necessary database changes (eg replacing extension metadata).
- setProcessesForTesting() : mixed
- Provides way to set processes property for phpunit tests - not for general use.
- uninstall() : mixed
- Remove all database references to an extension.
- addProcess() : mixed
- Add a process to the stacks for the extensions.
- filterInfosByStatus() : array<string|int, mixed>
- popProcess() : mixed
- Pop the top op from the stacks for the extensions.
- _createExtensionEntry() : bool
- _getInfoTypeHandler() : array<string|int, mixed>
- Find the $info and $typeManager for a $key
- _getMissingInfoTypeHandler() : array<string|int, mixed>
- Find the $info and $typeManager for a $key
- _removeExtensionEntry() : mixed
- _setExtensionActive() : mixed
- _updateExtensionEntry() : bool
Constants
STATUS_DISABLED
The extension config has been applied to database but deactivated.
public
mixed
STATUS_DISABLED
= 'disabled'
STATUS_DISABLED_MISSING
The extension was installed and is now disabled; the code is not accessible
public
mixed
STATUS_DISABLED_MISSING
= 'disabled-missing'
STATUS_INSTALLED
The extension is fully installed and enabled.
public
mixed
STATUS_INSTALLED
= 'installed'
STATUS_INSTALLED_MISSING
The extension is installed but the code is not accessible
public
mixed
STATUS_INSTALLED_MISSING
= 'installed-missing'
STATUS_UNINSTALLED
The extension code is visible, but nothing has been applied to DB
public
mixed
STATUS_UNINSTALLED
= 'uninstalled'
STATUS_UNKNOWN
The extension code is not locally accessible
public
mixed
STATUS_UNKNOWN
= 'unknown'
Properties
$defaultContainer
Default container.
public
CRM_Extension_Container_Basic|false
$defaultContainer
Note: Treat as private. This is only public to facilitate debugging.
$fullContainer
public
CRM_Extension_Container_Interface
$fullContainer
Note: Treat as private. This is only public to facilitate debugging.
$mapper
Mapper.
public
CRM_Extension_Mapper
$mapper
Note: Treat as private. This is only public to facilitate debugging.
$statuses
Statuses.
public
array<string|int, mixed>
$statuses
Format is (extensionKey => statusConstant)
Note: Treat as private. This is only public to facilitate debugging.
$typeManagers
Type managers.
public
array<string|int, mixed>
$typeManagers
Format is (typeName => CRM_Extension_Manager_Interface)
Note: Treat as private. This is only public to facilitate debugging.
$processes
Live process(es) per extension.
protected
array<string|int, mixed>
$processes
= []
Format is: { extensionKey => [ ['operation' => 'install|enable|uninstall|disable', 'phase' => 'queued|live|completed' ... ], ... }
The inner array is a stack, so the most recent current operation is the last entry. As this manager handles multiple extensions at once, here's the flow for an install operation.
$manager->install(['ext1', 'ext2']);
- }
- { ext1: ['install'], ext2: ['install'] }
- { ext1: ['install', 'installing'], ext2: ['install'] }
- { ext1: ['install'], ext2: ['install', 'installing'] }
- { ext1: ['install'], ext2: ['install'] }
- }
Methods
__construct()
Class constructor.
public
__construct(CRM_Extension_Container_Interface $fullContainer, CRM_Extension_Container_Basic|false $defaultContainer, CRM_Extension_Mapper $mapper, array<string|int, mixed> $typeManagers) : mixed
Parameters
- $fullContainer : CRM_Extension_Container_Interface
- $defaultContainer : CRM_Extension_Container_Basic|false
- $mapper : CRM_Extension_Mapper
- $typeManagers : array<string|int, mixed>
createInfoFromDB()
Auto-generate a place-holder for a missing extension using info from database.
public
createInfoFromDB(mixed $key) : CRM_Extension_Info|null
Parameters
- $key : mixed
Return values
CRM_Extension_Info|nulldisable()
Disable extension without removing record from db.
public
disable(string|array<string|int, mixed> $keys) : mixed
Parameters
- $keys : string|array<string|int, mixed>
-
One or more extension keys.
Tags
enable()
Add records of the extension to the database -- and enable it
public
enable(array<string|int, mixed> $keys) : mixed
Parameters
- $keys : array<string|int, mixed>
-
List of extension keys.
Tags
extensionIsBeingInstalledOrEnabled()
Determine if the extension specified is currently involved in an install or enable process. Just sugar code to make things more readable.
public
extensionIsBeingInstalledOrEnabled(string $key) : bool
Parameters
- $key : string
-
extension key
Return values
boolfindDisableRequirements()
Build a list of extensions to remove, in an order that will satisfy dependencies.
public
findDisableRequirements(array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
- $keys : array<string|int, mixed>
-
List of extensions to install.
Return values
array<string|int, mixed> —List of extension keys, including dependencies, in order of removal.
findInstallRequirements()
Build a list of extensions to install, in an order that will satisfy dependencies.
public
findInstallRequirements(array<string|int, mixed> $keys[, CRM_Extension_Info $info = NULL ]) : array<string|int, mixed>
Parameters
- $keys : array<string|int, mixed>
-
List of extensions to install.
- $info : CRM_Extension_Info = NULL
-
An extension info object that we should use instead of our local versions (eg. when checking for upgradeability).
Tags
Return values
array<string|int, mixed> —List of extension keys, including dependencies, in order of installation.
getActiveProcesses()
Return current processes for given extension.
public
getActiveProcesses(string $key) : array<string|int, mixed>
Parameters
- $key : string
-
extension key
Return values
array<string|int, mixed>getStatus()
Determine the status of an extension.
public
getStatus(mixed $key) : string
Parameters
- $key : mixed
Return values
string —constant self::STATUS_*
getStatuses()
Determine the status of all extensions.
public
getStatuses() : array<string|int, mixed>
Return values
array<string|int, mixed> —($key => status_constant)
install()
Add records of the extension to the database -- and enable it
public
install(string|array<string|int, mixed> $keys[, string $mode = 'install' ]) : mixed
Parameters
- $keys : string|array<string|int, mixed>
-
One or more extension keys.
- $mode : string = 'install'
-
install|enable
Tags
isEnabled()
Check if a given extension is installed and enabled
public
isEnabled(mixed $key) : bool
Parameters
- $key : mixed
Return values
boolisIncompatible()
Check if a given extension is incompatible with this version of CiviCRM
public
isIncompatible(mixed $key) : bool|array<string|int, mixed>
Parameters
- $key : mixed
Return values
bool|array<string|int, mixed>refresh()
public
refresh() : mixed
replace()
Install or upgrade the code for an extension -- and perform any necessary database changes (eg replacing extension metadata).
public
replace(string $tmpCodeDir) : mixed
This only works if the extension is stored in the default container.
Parameters
- $tmpCodeDir : string
-
Path to a local directory containing a copy of the new (inert) code.
Tags
setProcessesForTesting()
Provides way to set processes property for phpunit tests - not for general use.
public
setProcessesForTesting(mixed $processes) : mixed
Parameters
- $processes : mixed
uninstall()
Remove all database references to an extension.
public
uninstall(string|array<string|int, mixed> $keys) : mixed
Parameters
- $keys : string|array<string|int, mixed>
-
One or more extension keys.
Tags
addProcess()
Add a process to the stacks for the extensions.
protected
addProcess(array<string|int, mixed> $keys, string $process) : mixed
Parameters
- $keys : array<string|int, mixed>
-
extensionKey
- $process : string
-
one of: install|uninstall|enable|disable|installing|uninstalling|enabling|disabling
filterInfosByStatus()
protected
filterInfosByStatus(mixed $infos, mixed $filterStatuses) : array<string|int, mixed>
Parameters
- $infos : mixed
- $filterStatuses : mixed
Return values
array<string|int, mixed>popProcess()
Pop the top op from the stacks for the extensions.
protected
popProcess(array<string|int, mixed> $keys) : mixed
Parameters
- $keys : array<string|int, mixed>
-
extensionKey
_createExtensionEntry()
private
_createExtensionEntry(CRM_Extension_Info $info) : bool
Parameters
- $info : CRM_Extension_Info
Return values
bool_getInfoTypeHandler()
Find the $info and $typeManager for a $key
private
_getInfoTypeHandler(mixed $key) : array<string|int, mixed>
Parameters
- $key : mixed
Tags
Return values
array<string|int, mixed> —[CRM_Extension_Info, CRM_Extension_Manager_Interface]
_getMissingInfoTypeHandler()
Find the $info and $typeManager for a $key
private
_getMissingInfoTypeHandler(mixed $key) : array<string|int, mixed>
Parameters
- $key : mixed
Tags
Return values
array<string|int, mixed> —[CRM_Extension_Info, CRM_Extension_Manager_Interface]
_removeExtensionEntry()
private
_removeExtensionEntry(CRM_Extension_Info $info) : mixed
Parameters
- $info : CRM_Extension_Info
Tags
_setExtensionActive()
private
_setExtensionActive(CRM_Extension_Info $info, mixed $isActive) : mixed
Parameters
- $info : CRM_Extension_Info
- $isActive : mixed
_updateExtensionEntry()
private
_updateExtensionEntry(CRM_Extension_Info $info) : bool
Parameters
- $info : CRM_Extension_Info