1 | <?php |
||
10 | class Zookal_Mock_Model_Observer |
||
|
|||
11 | { |
||
12 | /** |
||
13 | * General Container for rewriting nodes entries |
||
14 | * |
||
15 | * @var array |
||
16 | */ |
||
17 | protected $_newConfigNodes = array(); |
||
18 | |||
19 | /** |
||
20 | * Only add these modules which are tightly coupled with the core and causes issues once active=>false |
||
21 | * Module Name => model name |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $_mappingModel = array( |
||
26 | 'Mage_Wishlist' => 'wishlist', |
||
27 | 'Mage_Weee' => 'weee', |
||
28 | 'Mage_Usa' => 'usa', |
||
29 | 'Mage_Tag' => 'tag', |
||
30 | 'Mage_Tax' => 'tax', |
||
31 | 'Mage_Shipping' => 'shipping', |
||
32 | 'Mage_Sales' => 'sales', |
||
33 | 'Mage_Review' => 'review', |
||
34 | 'Mage_Reports' => 'reports', |
||
35 | 'Mage_Rating' => 'rating', |
||
36 | 'Mage_ProductAlert' => 'productalert', |
||
37 | 'Mage_Newsletter' => 'newsletter', |
||
38 | 'Mage_Log' => 'log', |
||
39 | 'Mage_GoogleCheckout' => 'googlecheckout', |
||
40 | 'Mage_GiftMessage' => 'giftmessage', |
||
41 | 'Mage_Dataflow' => 'dataflow', |
||
42 | 'Mage_Catalog' => 'catalog', |
||
43 | 'Mage_Customer' => 'customer', |
||
44 | 'Mage_Cms' => 'cms', |
||
45 | 'Mage_Backup' => 'backup', |
||
46 | 'Mage_Adminhtml' => 'adminhtml', |
||
47 | 'Mage_Admin' => 'admin', |
||
48 | 'Mage_AdminNotification' => 'adminnotification', |
||
49 | ); |
||
50 | |||
51 | /** |
||
52 | * These methods will only be executed when that module has been disabled. |
||
53 | * |
||
54 | * @var array |
||
55 | */ |
||
56 | protected $_specialMethods = array( |
||
57 | 'Mage_Admin' => '_mageMockIncludePath', |
||
58 | 'Mage_Adminhtml' => '_mageMockIncludePath', |
||
59 | 'Mage_AdminNotification' => '_mageMockIncludePath', |
||
60 | 'Mage_Catalog' => '_mageCatalog', |
||
61 | 'Mage_Customer' => '_mageCustomer', |
||
62 | 'Mage_GiftMessage' => '_mageMockHelperIncludePath', |
||
63 | 'Mage_GoogleCheckout' => '_mageGoogleCheckout', |
||
64 | 'Mage_Log' => '_mageMockIncludePath', |
||
65 | 'Mage_ProductAlert' => '_mageMockHelper', |
||
66 | 'Mage_Review' => '_mageMockHelper', |
||
67 | 'Mage_Shipping' => '_mageMockHelperIncludePath', |
||
68 | 'Mage_Tag' => '_mageMockHelperIncludePath', |
||
69 | 'Mage_Tax' => '_mageTaxClass', |
||
70 | 'Mage_Usa' => '_mageMockHelper', |
||
71 | 'Mage_Wishlist' => '_mageMockHelper', |
||
72 | 'Mage_Weee' => '_mageMockIncludePath', |
||
73 | ); |
||
74 | |||
75 | /** |
||
76 | * only needed for the crontab because implemented on the two events always and default. |
||
77 | * For controller execution we're only observing controller_front_init_before which fires once |
||
78 | * |
||
79 | * @var int |
||
80 | */ |
||
81 | private $_singleton = 0; |
||
82 | |||
83 | /** |
||
84 | * To use this in a shell script (no cron) call it: Mage::getModel('zookal_mock/observer')->mockDisabledModules(); |
||
85 | * @fire always |
||
86 | * @fire default |
||
87 | * @fire controller_front_init_before |
||
88 | * @return null |
||
89 | */ |
||
90 | public function mockDisabledModules() |
||
124 | |||
125 | /** |
||
126 | * Runs a specialMethod if its found otherwise _mageVoid will be executed |
||
127 | * |
||
128 | * @param $moduleName |
||
129 | * |
||
130 | * @return array |
||
131 | */ |
||
132 | protected function _getSpecialMethod($moduleName) |
||
136 | |||
137 | /** |
||
138 | * Allows you to remove or add special methods. If the value of a key is an array then your class will be called. |
||
139 | */ |
||
140 | protected function _initSpecialMethods() |
||
144 | |||
145 | /** |
||
146 | * Special Handling when Mage_Adminhtml/Mage_Log/Mage_Tag is disabled and physically removed |
||
147 | */ |
||
148 | protected function _mageMockIncludePath() |
||
152 | |||
153 | /** |
||
154 | * Special Handling when Mage_GoogleCheckout is disabled. It has a dependency in Mage_Sales/etc/config.xml :-( |
||
155 | * |
||
156 | * @param array $o |
||
157 | */ |
||
158 | protected function _mageGoogleCheckout(array $o) |
||
173 | |||
174 | /** |
||
175 | * Special Handling when Mage_ProductAlert is disabled, when need to fake a helper |
||
176 | * |
||
177 | * @param array $o |
||
178 | */ |
||
179 | protected function _mageMockHelper(array $o) |
||
183 | |||
184 | /** |
||
185 | * Special Handling when Mage_ProductAlert is disabled, when need to fake a helper |
||
186 | * |
||
187 | * @param array $o |
||
188 | */ |
||
189 | protected function _mageMockHelperIncludePath(array $o) |
||
194 | |||
195 | /** |
||
196 | * Special case when Mage_Catalog is disabled and Mage_Widget is enabled |
||
197 | */ |
||
198 | protected function _mageCatalog() |
||
206 | |||
207 | /** |
||
208 | * Special case when Mage_CatalogIndex is enabled and Mage_Customer is disabled |
||
209 | * Mage_Customer needs the tax_class table name for joining |
||
210 | * |
||
211 | * @param array $o |
||
212 | */ |
||
213 | protected function _mageCustomer(array $o) |
||
217 | |||
218 | /** |
||
219 | * Special case when Mage_Tax is disabled and Mage_Customer is enabled |
||
220 | * Mage_Customer needs the tax_class table name for joining |
||
221 | * |
||
222 | * @param array $o |
||
223 | */ |
||
224 | protected function _mageTaxClass(array $o) |
||
228 | |||
229 | /** |
||
230 | * empty method for fallback |
||
231 | */ |
||
232 | protected function _mageVoid() |
||
235 | |||
236 | /** |
||
237 | * @return array |
||
238 | */ |
||
239 | protected function _getDisabledModules() |
||
253 | |||
254 | /** |
||
255 | * @param string $path |
||
256 | * @param string $value |
||
257 | */ |
||
258 | protected function _setConfigNode($path, $value) |
||
262 | |||
263 | /** |
||
264 | * runs setNode on getConfig |
||
265 | */ |
||
266 | protected function _processSetNodes() |
||
272 | |||
273 | /** |
||
274 | * refactor when used more than once |
||
275 | * |
||
276 | * @return array |
||
277 | */ |
||
278 | protected function _getAllPathPrefixes() |
||
292 | |||
293 | /** |
||
294 | * @return array |
||
295 | */ |
||
296 | public function getSpecialMethods() |
||
300 | |||
301 | /** |
||
302 | * @param array $specialMethods |
||
303 | * |
||
304 | * @return $this |
||
305 | */ |
||
306 | public function setSpecialMethods(array $specialMethods) |
||
311 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.