3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * A module is any software package that participates in the hook
14 * system, such as CiviCRM Module-Extension, a Drupal Module, or
18 * @copyright CiviCRM LLC https://civicrm.org/licensing
20 class CRM_Core_Module
{
28 * Is the module enabled.
38 * @param bool $is_active
40 public function __construct($name, $is_active) {
42 $this->is_active
= $is_active;
46 * Get a list of all known modules.
53 public static function getAll($fresh = FALSE) {
55 if ($fresh ||
!is_array($result)) {
56 $result = CRM_Extension_System
::singleton()->getMapper()->getModules();
57 // pseudo-module for core
58 $result[] = new CRM_Core_Module('civicrm', TRUE);
60 $config = CRM_Core_Config
::singleton();
61 $result = array_merge($result, $config->userSystem
->getModules());
67 * Get the status for each module.
69 * @param array $modules
70 * Array(CRM_Core_Module).
72 * Array(string $moduleName => string $statusCode).
73 * @see CRM_Extension_Manager::STATUS_INSTALLED
74 * @see CRM_Extension_Manager::STATUS_DISABLED
76 public static function collectStatuses($modules) {
78 foreach ($modules as $module) {
79 $statuses[$module->name
] = $module->is_active ? CRM_Extension_Manager
::STATUS_INSTALLED
: CRM_Extension_Manager
::STATUS_DISABLED
;