Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
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 | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * This class stores logic for managing CiviCRM extensions. | |
14 | * | |
15 | * @package CRM | |
ca5cec67 | 16 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
17 | */ |
18 | class CRM_Extension_Manager_Module extends CRM_Extension_Manager_Base { | |
19 | ||
e0ef6999 EM |
20 | /** |
21 | * @param CRM_Extension_Mapper $mapper | |
22 | */ | |
6a488035 TO |
23 | public function __construct(CRM_Extension_Mapper $mapper) { |
24 | parent::__construct(FALSE); | |
25 | $this->mapper = $mapper; | |
26 | } | |
27 | ||
e0ef6999 EM |
28 | /** |
29 | * @param CRM_Extension_Info $info | |
30 | */ | |
6a488035 TO |
31 | public function onPreInstall(CRM_Extension_Info $info) { |
32 | $this->callHook($info, 'install'); | |
33 | $this->callHook($info, 'enable'); | |
34 | } | |
35 | ||
e0ef6999 EM |
36 | /** |
37 | * @param CRM_Extension_Info $info | |
38 | */ | |
3d0e24ec | 39 | public function onPostPostInstall(CRM_Extension_Info $info) { |
40 | $this->callHook($info, 'postInstall'); | |
41 | } | |
42 | ||
e0ef6999 EM |
43 | /** |
44 | * @param CRM_Extension_Info $info | |
100fef9d | 45 | * @param string $hookName |
e0ef6999 | 46 | */ |
6a488035 TO |
47 | private function callHook(CRM_Extension_Info $info, $hookName) { |
48 | try { | |
49 | $file = $this->mapper->keyToPath($info->key); | |
0db6c3e1 TO |
50 | } |
51 | catch (CRM_Extension_Exception $e) { | |
6a488035 TO |
52 | return; |
53 | } | |
54 | if (!file_exists($file)) { | |
55 | return; | |
56 | } | |
57 | include_once $file; | |
58 | $fnName = "{$info->file}_civicrm_{$hookName}"; | |
59 | if (function_exists($fnName)) { | |
60 | $fnName(); | |
61 | } | |
62 | } | |
63 | ||
e0ef6999 EM |
64 | /** |
65 | * @param CRM_Extension_Info $info | |
66 | * | |
67 | * @return bool | |
68 | */ | |
6a488035 TO |
69 | public function onPreUninstall(CRM_Extension_Info $info) { |
70 | $this->callHook($info, 'uninstall'); | |
71 | return TRUE; | |
72 | } | |
73 | ||
e0ef6999 EM |
74 | /** |
75 | * @param CRM_Extension_Info $info | |
76 | */ | |
6a488035 | 77 | public function onPostUninstall(CRM_Extension_Info $info) { |
6a488035 TO |
78 | } |
79 | ||
e0ef6999 EM |
80 | /** |
81 | * @param CRM_Extension_Info $info | |
82 | */ | |
6a488035 TO |
83 | public function onPreDisable(CRM_Extension_Info $info) { |
84 | $this->callHook($info, 'disable'); | |
85 | } | |
86 | ||
e0ef6999 EM |
87 | /** |
88 | * @param CRM_Extension_Info $info | |
89 | */ | |
6a488035 TO |
90 | public function onPreEnable(CRM_Extension_Info $info) { |
91 | $this->callHook($info, 'enable'); | |
92 | } | |
96025800 | 93 | |
6a488035 | 94 | } |