class Base
{
public $value = 1;
}
class Wire
{
//List of classes I'll have to load
private static $load = array("Foo", "Hello");
//Template of the Bootstrap class
private static $template = NULL;
//Wire everything up
public function Up()
{
//Get the bootstrap template
self::GetTemplate();
//Get each class
foreach(self::$load as $class)
{
//Load it...
require_once "./class/" . $class . ".php";
//Build the static shell
$bootstrap = str_replace("%CLASS%", $class, self::$template);
eval($bootstrap);
}
}
//Get the tempalte of the bootstrap class
private function GetTemplate()
{
if(self::$template === NULL)
{
//I've stored it in a separate file
self::$template = file_get_contents("./class/Bootstrap.php");
}
}
}
Wire::Up();
//This is the Bootstrap class
//It offers a static shell for other instatiated classes
class %CLASS%
{
public static $instance = NULL;
public function __callStatic($method, $arguments)
{
if(self::$instance === NULL)
{
$class = get_called_class() . "Controller";
self::$instance = new $class();
}
call_user_func_array(array(self::$instance, $method), $arguments);
}
}
That's the Base class, for testing purpouses only
class Base
{
public $value = 1;
}