|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @category Zookal_Mock |
|
4
|
|
|
* @package Model |
|
5
|
|
|
* @author Cyrill Schumacher | {firstName}@{lastName}.fm | @SchumacherFM |
|
6
|
|
|
* @copyright Copyright (c) Zookal Pty Ltd |
|
7
|
|
|
* @license OSL - Open Software Licence 3.0 | http://opensource.org/licenses/osl-3.0.php |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Only usable in index.php: |
|
12
|
|
|
* Mage::run($mageRunCode, $mageRunType, array( |
|
13
|
|
|
* 'config_model' => 'Zookal_Mock_Model_Config' |
|
14
|
|
|
* )); |
|
15
|
|
|
* |
|
16
|
|
|
* Class Zookal_Mock_Model_Config |
|
17
|
|
|
*/ |
|
18
|
|
|
class Zookal_Mock_Model_Config extends Mage_Core_Model_Config |
|
|
|
|
|
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* Key = active Module name => values inactive Module names whose dependency can be removed. |
|
22
|
|
|
* If you find more please send me a PR. |
|
23
|
|
|
* Maybe this config could also reside in a xml file. |
|
24
|
|
|
* @var array |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $_dependencyLiars = array( |
|
27
|
|
|
'Mage_Reports' => array('Mage_Sales', 'Mage_Customer'), |
|
28
|
|
|
'Mage_Log' => array('Mage_Customer'), |
|
29
|
|
|
'Mage_Tax' => array('Mage_Customer'), |
|
30
|
|
|
'Mage_Poll' => array('Mage_Cms'), |
|
31
|
|
|
'Mage_Newsletter' => array('Mage_Widget'), |
|
32
|
|
|
'Mage_Catalog' => array('Mage_Cms'), |
|
33
|
|
|
'Mage_CatalogRule' => array('Mage_Customer'), |
|
34
|
|
|
'Mage_CatalogIndex' => array('Mage_CatalogRule'), |
|
35
|
|
|
'Mage_Checkout' => array('Mage_CatalogInventory'), |
|
36
|
|
|
'Mage_Customer' => array('Mage_Dataflow'), |
|
37
|
|
|
'Mage_Persistent' => array('Mage_Adminhtml'), |
|
38
|
|
|
'Mage_Captcha' => array('Mage_Adminhtml'), |
|
39
|
|
|
'VinaiKopp_LoginLog' => array('Mage_Adminhtml'), |
|
40
|
|
|
); |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Removes the dependencies for some modules configured in $_dependencyLiars |
|
44
|
|
|
* e.g. if Mage_Log is active and Mage_Customer is disabled then remove Mage_Customer dependency |
|
45
|
|
|
* |
|
46
|
|
|
* @param array $modules |
|
47
|
|
|
* |
|
48
|
|
|
* @return array |
|
49
|
|
|
*/ |
|
50
|
|
|
protected function _sortModuleDepends($modules) |
|
51
|
|
|
{ |
|
52
|
|
|
$modules = $this->removeDependencies($modules); |
|
53
|
|
|
return parent::_sortModuleDepends($modules); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param array $modules |
|
58
|
|
|
* |
|
59
|
|
|
* @return array |
|
60
|
|
|
*/ |
|
61
|
|
|
public function removeDependencies(array $modules) |
|
62
|
|
|
{ |
|
63
|
|
|
$disabledModules = $this->getDisabledModules($modules); |
|
64
|
|
|
foreach ($modules as $moduleName => $config) { |
|
65
|
|
|
if (false === isset($this->_dependencyLiars[$moduleName]) || false === $config['active']) { |
|
66
|
|
|
continue; |
|
67
|
|
|
} |
|
68
|
|
|
foreach ($this->_dependencyLiars[$moduleName] as $inactiveModule) { |
|
69
|
|
|
if (true === isset($disabledModules[$inactiveModule])) { // check if it's really disabled |
|
70
|
|
|
unset($modules[$moduleName]['depends'][$inactiveModule]); // remove dependency |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
return $modules; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @param array $modules |
|
79
|
|
|
* |
|
80
|
|
|
* @return array |
|
81
|
|
|
*/ |
|
82
|
|
|
public function getDisabledModules(array $modules) |
|
83
|
|
|
{ |
|
84
|
|
|
$_disabledModules = array(); |
|
85
|
|
|
foreach ($modules as $moduleName => $node) { |
|
86
|
|
|
$isDisabled = $node['active'] !== true; |
|
87
|
|
|
if (true === $isDisabled) { |
|
88
|
|
|
$_disabledModules[$moduleName] = $moduleName; |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
return $_disabledModules; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @return array |
|
96
|
|
|
*/ |
|
97
|
|
|
public function getDependencyLiars() |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->_dependencyLiars; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|
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.