Merge pull request #15595 from eileenmcnaughton/dedupe3
[civicrm-core.git] / CRM / Extension / Manager / Base.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2020 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28 /**
29 * The extension manager handles installing, disabling enabling, and
30 * uninstalling extensions.
31 *
32 * @package CRM
33 * @copyright CiviCRM LLC (c) 2004-2020
34 */
35 class CRM_Extension_Manager_Base implements CRM_Extension_Manager_Interface {
36
37 /**
38 * Whether to automatically uninstall and install during 'replace'.
39 *
40 * @var bool
41 */
42 public $autoReplace;
43
44 /**
45 * @param bool $autoReplace
46 * Whether to automatically uninstall and install during 'replace'.
47 */
48 public function __construct($autoReplace = FALSE) {
49 $this->autoReplace = $autoReplace;
50 }
51
52 /**
53 * @inheritDoc
54 *
55 * @param CRM_Extension_Info $info
56 */
57 public function onPreInstall(CRM_Extension_Info $info) {
58 }
59
60 /**
61 * @inheritDoc
62 *
63 * @param CRM_Extension_Info $info
64 */
65 public function onPostInstall(CRM_Extension_Info $info) {
66 }
67
68 /**
69 * @inheritDoc
70 *
71 * @param CRM_Extension_Info $info
72 */
73 public function onPostPostInstall(CRM_Extension_Info $info) {
74 }
75
76 /**
77 * @inheritDoc
78 *
79 * @param CRM_Extension_Info $info
80 */
81 public function onPreEnable(CRM_Extension_Info $info) {
82 }
83
84 /**
85 * @inheritDoc
86 *
87 * @param CRM_Extension_Info $info
88 */
89 public function onPostEnable(CRM_Extension_Info $info) {
90 }
91
92 /**
93 * @inheritDoc
94 *
95 * @param CRM_Extension_Info $info
96 */
97 public function onPreDisable(CRM_Extension_Info $info) {
98 }
99
100 /**
101 * @inheritDoc
102 *
103 * @param CRM_Extension_Info $info
104 */
105 public function onPostDisable(CRM_Extension_Info $info) {
106 }
107
108 /**
109 * @inheritDoc
110 *
111 * @param CRM_Extension_Info $info
112 */
113 public function onPreUninstall(CRM_Extension_Info $info) {
114 }
115
116 /**
117 * @inheritDoc
118 *
119 * @param CRM_Extension_Info $info
120 */
121 public function onPostUninstall(CRM_Extension_Info $info) {
122 }
123
124 /**
125 * @inheritDoc
126 *
127 * @param CRM_Extension_Info $oldInfo
128 * @param CRM_Extension_Info $newInfo
129 */
130 public function onPreReplace(CRM_Extension_Info $oldInfo, CRM_Extension_Info $newInfo) {
131 if ($this->autoReplace) {
132 $this->onPreUninstall($oldInfo);
133 $this->onPostUninstall($oldInfo);
134 }
135 }
136
137 /**
138 * @inheritDoc
139 *
140 * @param CRM_Extension_Info $oldInfo
141 * @param CRM_Extension_Info $newInfo
142 */
143 public function onPostReplace(CRM_Extension_Info $oldInfo, CRM_Extension_Info $newInfo) {
144 if ($this->autoReplace) {
145 $this->onPreInstall($oldInfo);
146 $this->onPostInstall($oldInfo);
147 }
148 }
149
150 }