Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few bug fixes and changes to make the injector play better with existing code. #477

Merged
merged 1 commit into from
May 22, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static protected function type_mismatch() {
* @return Config
*/
static public function inst() {
if (!self::$instance) self::$instance = singleton('Config');
if (!self::$instance) self::$instance = new Config();
return self::$instance;
}

Expand Down
2 changes: 1 addition & 1 deletion core/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ function singleton($className) {
if(!is_string($className)) user_error("singleton() passed bad class_name: " . var_export($className,true), E_USER_ERROR);
if(!isset($_SINGLETONS[$className])) {
if(!class_exists($className)) user_error("Bad class to singleton() - $className", E_USER_ERROR);
$_SINGLETONS[$className] = Object::strong_create($className,null, true);
$_SINGLETONS[$className] = Injector::inst()->get($className);
if(!$_SINGLETONS[$className]) user_error("singleton() Unknown class '$className'", E_USER_ERROR);
}
return $_SINGLETONS[$className];
Expand Down
3 changes: 1 addition & 2 deletions core/Object.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ public static function strong_create() {
$class = self::$strong_classes[$class];
}

$reflector = new ReflectionClass($class);
return $reflector->newInstanceArgs($args);
return Injector::inst()->createWithArgs($class, $args);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion model/Versioned.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static function reset() {
* The first stage is consiedered the 'default' stage, the last stage is
* considered the 'live' stage.
*/
function __construct($stages) {
function __construct($stages=array('Stage','Live')) {
parent::__construct();

if(!is_array($stages)) {
Expand Down