From e1508d9ff373d28b8d0263e9143804cb3bb47b38 Mon Sep 17 00:00:00 2001 From: Benjamin Cremer Date: Mon, 10 Feb 2014 09:06:00 +0100 Subject: [PATCH] SW-7946 - Set php settings during kernel construction. --- engine/Library/Enlight/Application.php | 3 +++ engine/Shopware/Components/ConfigLoader.php | 2 ++ engine/Shopware/Kernel.php | 24 ++++++++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/engine/Library/Enlight/Application.php b/engine/Library/Enlight/Application.php index 19121e728a1..3b982f68064 100644 --- a/engine/Library/Enlight/Application.php +++ b/engine/Library/Enlight/Application.php @@ -349,6 +349,7 @@ public static function Instance() * This method sets the configuration of the options parameter into the different configurations. * If the options are not an array, the loadConfig method should be used to convert the options into an array. * + * @deprecated 4.2 * @param array $options * @return Enlight_Application */ @@ -406,6 +407,7 @@ public function getOption($key, $default = null) /** * Sets the php settings from the config * + * @deprecated 4.2 * @param array $settings * @param string $prefix * @return Enlight_Application @@ -426,6 +428,7 @@ public function setPhpSettings(array $settings, $prefix = '') /** * Sets include paths * + * @deprecated 4.2 * @param array $paths * @return Enlight_Application */ diff --git a/engine/Shopware/Components/ConfigLoader.php b/engine/Shopware/Components/ConfigLoader.php index 2eda0ac75c6..01928b1a5b0 100644 --- a/engine/Shopware/Components/ConfigLoader.php +++ b/engine/Shopware/Components/ConfigLoader.php @@ -99,6 +99,8 @@ public function loadConfig($file) ); } + $config = array_change_key_case($config, CASE_LOWER); + return $config; } diff --git a/engine/Shopware/Kernel.php b/engine/Shopware/Kernel.php index 21b4b67c7eb..c6698d659ab 100644 --- a/engine/Shopware/Kernel.php +++ b/engine/Shopware/Kernel.php @@ -103,6 +103,10 @@ public function __construct($environment, $debug) $this->name = 'Shopware'; $this->initializeConfig(); + + if (!empty($this->config['phpsettings'])) { + $this->setPhpSettings($this->config['phpsettings']); + } } /** @@ -261,6 +265,24 @@ protected function initializeConfig() define("_MPDF_TTFONTDATAPATH", $this->getRootDir() .'/cache/mpdf/ttfontdata/'); } + /** + * Sets the php settings from the config + * + * @param array $settings + * @param string $prefix + */ + public function setPhpSettings(array $settings, $prefix = '') + { + foreach ($settings as $key => $value) { + $key = empty($prefix) ? $key : $prefix . $key; + if (is_scalar($value)) { + ini_set($key, $value); + } elseif (is_array($value)) { + $this->setPhpSettings($value, $key . '.'); + } + } + } + /** * Creates a new instance of the Shopware application */ @@ -538,6 +560,6 @@ public function getConfig() */ public function getHttpCacheConfig() { - return is_array($this->config['httpCache']) ? $this->config['httpCache'] : array(); + return is_array($this->config['httpcache']) ? $this->config['httpcache'] : array(); } }