Permalink
Browse files

Added base_path to init and made exits testable

Signed-off-by: Darren Hill <dchill42@gmail.com>
  • Loading branch information...
1 parent 9b7f2f8 commit 030bfea15abfc1e23262dd40acb860e0a98e42e4 @dchill42 dchill42 committed Feb 4, 2014
Showing with 11 additions and 6 deletions.
  1. +1 −0 index.php
  2. +10 −6 system/core/Xylophone.php
View
@@ -229,6 +229,7 @@
'environment' => $environment,
'ns_paths' => array_merge(array($application_namespace => $application_folder), $namespace_paths),
'view_paths' => array($view_folder),
+ 'base_path' => BASEPATH.DIRECTORY_SEPARATOR,
'system_path' => $system_path,
'resolve_bases' => $resolve_bases,
'override_core' => $override_core,
@@ -26,6 +26,7 @@
* @filesource
*/
namespace Xylophone\core;
+use \RuntimeException;
defined('BASEPATH') OR exit('No direct script access allowed');
@@ -39,6 +40,7 @@
*
* @package Xylophone
* @subpackage core
+ * @codeCoverageIgnore
*/
class AutoloadException extends \Exception { }
@@ -154,10 +156,11 @@ public static function instance($init = null)
if (!$app && !$ns) {
// Fail out
header('HTTP/1.1 503 Service Unavailable.', true, 503);
- echo 'The global namespace is reserved for application classes. ';
- echo 'Please specify a namespace for your additional path in the following file: '.
+ $msg = 'The global namespace is reserved for application classes. '.
+ 'Please specify a namespace for your additional path in the following file: '.
basename($_SERVER['PHP_SELF']);
- exit(EXIT_CONFIG);
+ echo $msg;
+ throw new RuntimeException($msg);
}
// Resolve the path
@@ -174,10 +177,11 @@ public static function instance($init = null)
if (!$resolved) {
// Fail out
header('HTTP/1.1 503 Service Unavailable.', true, 503);
- echo ($app ? 'Your application folder path does not appear to be set correctly.' :
+ $msg = ($app ? 'Your application folder path does not appear to be set correctly.' :
'The "'.$ns.'" namespace path does not appear to be set correctly.').
' Please fix it in the following file: '.basename($_SERVER['PHP_SELF']);
- exit(EXIT_CONFIG);
+ echo $msg;
+ throw new RuntimeException($msg);
}
// Try to include the file
@@ -221,7 +225,7 @@ public function initialize($init)
// Set base and system paths and resolve bases with trailing slashes
// These should all have been cleaned in instance()
- $this->base_path = BASEPATH;
+ $this->base_path = isset($init['base_path']) ? $init['base_path'] : BASEPATH;
$this->system_path = isset($init['system_path']) ? $init['system_path'] :
dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR;
$this->resolve_bases = isset($init['resolve_bases']) ? $init['resolve_bases'] : array('');

0 comments on commit 030bfea

Please sign in to comment.