small configuration refactoring
git-svn-id: https://svn.apache.org/repos/asf/shindig/branches/php_namespace_refactoring@1201264 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/php/config/container.php b/php/config/container.php
index 95664d7..8679648 100644
--- a/php/config/container.php
+++ b/php/config/container.php
@@ -44,7 +44,7 @@
* );
*
*/
-$shindigConfig = array(
+return array(
// Show debug backtrace's. Disable this on a production site
'debug' => true,
// do real file_exist checks? Turning this off can be a big performance gain on prod servers but also risky & less verbose errors
diff --git a/php/config/test.php b/php/config/test.php
index 2a07f51..6343fca 100644
--- a/php/config/test.php
+++ b/php/config/test.php
@@ -22,7 +22,7 @@
* this configuration overrides some values for unit testing purposes
* you should not use these settings in production
*/
-$shindigConfig = array(
+return array(
'compress_javascript' => false,
'private_key_file' => realpath(dirname(__FILE__) . '/../test/certs') . '/private.key',
'public_key_file' => realpath(dirname(__FILE__) . '/../test/certs') . '/public.crt',
diff --git a/php/index.php b/php/index.php
index a9b9066..91d1324 100644
--- a/php/index.php
+++ b/php/index.php
@@ -21,4 +21,5 @@
include 'src/apache/shindig/bootstrap.php';
$frontController = new \apache\shindig\FrontController();
+$frontController->setLocalConfig(__DIR__ . '/config/local.php');
$frontController->run();
\ No newline at end of file
diff --git a/php/src/apache/shindig/FrontController.php b/php/src/apache/shindig/FrontController.php
index ffe2ba2..2642fc4 100644
--- a/php/src/apache/shindig/FrontController.php
+++ b/php/src/apache/shindig/FrontController.php
@@ -23,7 +23,15 @@
*/
class FrontController {
+ private $localConfig;
+
+ public function setLocalConfig($localConfig) {
+ $this->localConfig = $localConfig;
+ }
+
public function run() {
+ Config::loadConfig($this->localConfig);
+
$this->checkServerConfig();
//get servlet map and prefix the servlet paths
diff --git a/php/src/apache/shindig/bootstrap.php b/php/src/apache/shindig/bootstrap.php
index db5c293..8f363d8 100644
--- a/php/src/apache/shindig/bootstrap.php
+++ b/php/src/apache/shindig/bootstrap.php
@@ -57,10 +57,10 @@
$mapperLoader->register();
-$extensionClassPaths = \apache\shindig\common\Config::get('extension_class_paths');
-
-if (! is_array($extensionClassPaths)) {
- $extensionClassPaths = array($extensionClassPaths);
-}
-
-$loader->registerPrefixFallbacks($extensionClassPaths);
\ No newline at end of file
+//$extensionClassPaths = \apache\shindig\common\Config::get('extension_class_paths');
+//
+//if (! is_array($extensionClassPaths)) {
+// $extensionClassPaths = array($extensionClassPaths);
+//}
+//
+//$loader->registerPrefixFallbacks($extensionClassPaths);
\ No newline at end of file
diff --git a/php/src/apache/shindig/common/Config.php b/php/src/apache/shindig/common/Config.php
index 280875d..db272eb 100644
--- a/php/src/apache/shindig/common/Config.php
+++ b/php/src/apache/shindig/common/Config.php
@@ -27,7 +27,7 @@
class Config {
/**
*
- * @var boolean
+ * @var array
*/
private static $config = false;
@@ -36,19 +36,16 @@
* @global array $shindigConfig
* @param string $local
*/
- static public function loadConfig($local = 'local') {
- global $shindigConfig;
+ public static function loadConfig($localConfigPath = null) {
if (! self::$config) {
// load default configuration
- require realpath(dirname(__FILE__) . "/../../../../config") . '/container.php';
- self::$config = $shindigConfig;
- if ($local) {
- $localConfigPath = realpath(dirname(__FILE__) . "/../../../../config") . '/' . $local . '.php';
+ self::$config = require realpath(dirname(__FILE__) . "/../../../../config") . '/container.php';
+ if ($localConfigPath) {
if (file_exists($localConfigPath)) {
// include local.php if it exists and merge the config arrays.
// the second array values overwrites the first one's
- require $localConfigPath;
- self::$config = array_merge(self::$config, $shindigConfig);
+ $localConfig = require $localConfigPath;
+ self::$config = array_merge(self::$config, $localConfig);
}
}
}
@@ -59,10 +56,7 @@
*
* @param array $tconfig
*/
- static function setConfig($tconfig) {
- if (!is_array(self::$config))
- self::loadConfig();
-
+ public static function setConfig($tconfig) {
self::$config = array_merge(self::$config, $tconfig);
}
@@ -72,10 +66,7 @@
* @return array
* @throws ConfigException
*/
- static function get($key) {
- if (! self::$config) {
- self::loadConfig();
- }
+ public static function get($key) {
if (isset(self::$config[$key])) {
return self::$config[$key];
} else {
@@ -92,10 +83,7 @@
* @param $key string Configuration key to set the value of.
* @param $value string Value to assign to the specified key.
*/
- static function set($key, $value) {
- if (! self::$config) {
- self::loadConfig();
- }
+ public static function set($key, $value) {
self::$config[$key] = $value;
}
}
diff --git a/php/src/apache/shindig/gadgets/GadgetFeatureRegistry.php b/php/src/apache/shindig/gadgets/GadgetFeatureRegistry.php
index 1e0f51c..48c9d22 100644
--- a/php/src/apache/shindig/gadgets/GadgetFeatureRegistry.php
+++ b/php/src/apache/shindig/gadgets/GadgetFeatureRegistry.php
@@ -24,8 +24,6 @@
* under the License.
*/
-require_once 'external/jsmin-php/jsmin.php';
-
/**
* Class that deals with the processing, loading and dep resolving of the gadget features
* Features are javascript libraries that provide an API, like 'opensocial' or 'settitle'