All pastes #634026 Raw Edit

Untitled

public text v1 · immutable
#634026 ·published 2007-07-26 03:15 UTC
rendered paste body
<?php
function __autoload($filename)
{
	$filename = INC_CLASS_DIR . strtolower($filename) . '.class.php';

	try
	{
		if(file_exists($filename)){
			require_once($filename);
		} else {
			throw new Exception('Unable to load file: ' . $filename);
		}
	} 
	Catch(Exception $e)
	{
		echo $e;
	}
}

interface iController
{
	public function scaffold();
}

class Controller implements iController
{
	public function __construct()
	{
		$this->mysql = new mysqli('a', 'b', 'c', 'd');

		$classes = array(
							0				=>	array('session'		=>	array('Session', array(&$this->mysql))),
							1				=>	array('auth'		=>	array('Auth', array(&$this->mysql))),
							2				=>	array('path'		=>	array('Path_Builder', array(0))),
							3				=>	array('load'		=>	array('Loader',	array(0))),
							4				=>	array('conf'		=>	array('Conf', array())),
							5				=>	array('uri'			=>	array('Uri', array())),
							6				=>	array('location'	=>	array('Locations', array(&$this->mysql))),
							7				=>	array('form'		=>	array('Form_Builder', array())),
							8				=>	array('sock'		=>	array('Socket', array())),
							9				=>	array('paginate'	=>	array('Pagination',	array($this->uri->segment(2)))),
						);

		if(is_array($classes)){
			foreach($classes as $class_idx => $class_array){
				foreach($class_array as $class_ref => $class_load_info){
					if(!is_object($this->$class_ref)){
						$this->$class_ref = new ReflectionClass($class_load_info['0']);
						$this->$class_ref = $this->$class_ref->newInstanceArgs($class_load_info['1']);
					}
				}
			}
		}
	}
	
	public function scaffold()
	{
		// ...	
	}
}
?>