Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

Commit

Permalink
update config path + use full composer autoload
Browse files Browse the repository at this point in the history
  • Loading branch information
devthejo committed Jun 28, 2016
1 parent 55d049b commit 15c7f5e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
34 changes: 12 additions & 22 deletions App.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
namespace RedCat\Framework;
use RedCat\Ding\Di;
use RedCat\Debug\ErrorHandler;
use RedCat\Autoload\Autoload;
class App extends Di{
protected $autoload;
protected $loader;
protected static $singleton;
static function get(){
if(!isset(static::$singleton))
Expand All @@ -15,18 +14,19 @@ static function set(){
if(func_num_args())
static::$singleton = func_get_arg(0);
else{
$config = [REDCAT.'.config.php'];
$config = [REDCAT.'config/default.php'];
if(REDCAT_CWD!=REDCAT)
$config[] = REDCAT_CWD.'.config.php';
$config[] = REDCAT_CWD.'.config.env.php';
$config[] = REDCAT_CWD.'.config.app.php';
$config[] = REDCAT_CWD.'config/default.php';
$config[] = REDCAT_CWD.'config/env.php';
$config[] = REDCAT_CWD.'config/app.php';
static::$singleton = static::load($config);
}
}
static function bootstrap($configMap=null){
if($configMap)
self::set(self::load($configMap));
static function bootstrap($loader=null){
$app = static::get();
if($loader){
$app['loader'] = $loader;
}
if(isset($app['dev'])&&isset($app['dev']['php'])&&$app['dev']['php']){
$app->create(ErrorHandler::class,[$app['dev']['php']])->handle();
}
Expand All @@ -40,22 +40,12 @@ static function bootstrap($configMap=null){
header('Location: /500',true,302);
});
}
if(isset($app['autoload'])){
if($app['loader']&&isset($app['autoload'])){
foreach((array)$app['autoload'] as $autoload){
call_user_func_array([$app,'autoload'],(array)$autoload);
list($dir,$ns) = $autoload;
$app['loader']->addPsr4($ns,$dir);
}
}
return $app;
}
function autoload($base_dir=null,$prefix=''){
if(!isset($this->autoload)){
$this->autoload = $this->create(Autoload::class);
$this->autoload->splRegister();
}
if(is_array($base_dir))
$this->autoload->addNamespaces($base_dir);
elseif(func_num_args()>=1)
$this->autoload->addNamespace($prefix,$base_dir);
return $this->autoload;
}
}
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"require": {
"php": ">=5.6.0",
"redcatphp/artist": "dev-master",
"redcatphp/autoload": "dev-master",
"redcatphp/ding": "dev-master",
"redcatphp/datamap": "dev-master",
"redcatphp/debug": "dev-master",
Expand Down

0 comments on commit 15c7f5e

Please sign in to comment.