Skip to content

Commit c6b31c1

Browse files
committed
Add cache for magento config (when run in static mode)
1 parent d773467 commit c6b31c1

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/Type/Mage/MethodReturnTypeDetector.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
abstract class MethodReturnTypeDetector
1616
{
17+
protected static $config;
18+
1719
abstract protected static function getMethodName(): string;
1820
abstract protected function getMagentoClassName(string $identifier): string;
1921

@@ -49,14 +51,23 @@ protected function getTypeFromExpr(MethodReflection $methodReflection, $methodCa
4951
/**
5052
* Load Magento XML configuration
5153
*
52-
* @return MagentoCore
54+
* @return MagentoCore | \Mage_Core_Model_Config
5355
*/
54-
protected function getMagentoConfig(): MagentoCore
56+
protected function getMagentoConfig()
5557
{
56-
$config = new MagentoCore();
57-
$config->loadBase();
58-
$config->loadModules();
58+
if (self::$config) {
59+
return self::$config;
60+
}
5961

60-
return $config;
62+
//change this to DI of staticReflection config
63+
if (\defined('staticReflection')) {
64+
$config = new MagentoCore();
65+
$config->loadBase();
66+
$config->loadModules();
67+
} else {
68+
$config = \Mage::app()->getConfig();
69+
}
70+
self::$config = $config;
71+
return self::$config;
6172
}
6273
}

0 commit comments

Comments
 (0)