Sys Loader

<?php
final class Loader {
	protected $registry;
    
	public function __construct($registry) {		
		$this->registry = $registry;
	}
	
	public function __get($key) {
		return $this->registry->get($key);
	}

	public function __set($key, $value) {		
		$this->registry->set($key, $value);		    
	}

	
	public function model($model) {
		
				$path = PATH_MODEL .'/'. strtolower($model) .'.php';				
				if(file_exists($path)){
						require($path);
						$this->registry->set($model, new $model());
					}
				else
					echo "Model tidak ditemukan";	
	}

	
			public function view($view,$data=array()) {
				$path = PATH_VIEW . '/' . $view . '.php';
				if (file_exists($path)) {					
					  extract($data);					
		      	ob_start();		      
			  		require($path);		      
			  		$this->output = ob_get_contents();		
		      	ob_end_clean();		      		
						echo $this->output;
		    	} 
		    else {
						echo "View tidak ditemukan";
						exit();				
		    }
			}

	
}


?>

0 comments:

Post a Comment

 

Copyright 2013 Download Lagu Gratis: Sys Loader Template by Casino Critic | Ping!. Powered by Blogger