вот класс коре
class Core
{
private static $_instance = null;
private $_loaded = array();
private $_tools = array();
private $_configs = null;
public static function __instance($configs = null)
{
if (self::$_instance == null)
self::$_instance = new self();
$core = self::$_instance;
if ($core->_configs == null)
$core->_configs = $configs;
return self::$_instance;
}
public static function load($file, $dir = '')
{
$core = self::__instance();
$config = $core->_configs['core'];
$config['_main'] = $core->_configs['_main'];
if (!isset($core->_loaded[$file]))
{
if (isset($dir) && is_readable($dir . $file . '.php'))
{
include_once $dir . $file . '.php';
$this->_loaded[$file] = $dir . $file . '.php';
}
else if (is_array($config['dirs']))
{
foreach ($config['dirs'] as $dir)
{
echo $dir . $file . '.php<br>';
if (is_readable($dir . $file . '.php'))
{
include_once $dir . $file . '.php';
$core->_loaded[$file] = $dir . $file . '.php';
break;
}
}
}
}
else
include_once $core->_loaded[$file];
}
public function set($key, $value, $instance = '__instance')
{
if (!isset($this->_tools[$key]))
$this->_tools[$key] = array($value, $instance);
}
public function get($key, $args = null)
{
if (isset($this->_tools[$key]))
{
$class = $this->_tools[$key][0];
$instance = $this->_tools[$key][1];
$obj = $this->_factory($key, $class, $args, $instance);
$obj->__core = self::__instance();
return $obj;
}
}
protected function _factory($key, $class, $args, $instance)
{
if (is_object($class))
return $class;
if (!class_exists($class))
$this->load($class);
if (class_exists($class))
{
if (isset($this->_configs[$key]) && is_callable(array($class, '__configure')))
call_user_func(array($class, '__configure'), $this->_configs[$key]);
if (is_callable(array($class, $instance)))
return call_user_func_array(array($class, $instance), $args);
else if ($args == null)
return new $class();
else
{
$reflection = new ReflectionClass($class);
return $reflection->newInstanceArgs($args);
}
}
}
}
если я уберу эти строчки из метода _factory то все ок:
if (is_callable(array($class, $instance)))
return call_user_func_array(array($class, $instance), $args);
PS аутолоадер это Core::load
http://77.39.20.54/