All pastes #511714 Raw Edit

Anonymous

public php v1 · immutable
#511714 ·published 2007-05-26 16:30 UTC
rendered paste body
<?php    class DispatchException extends Exception { }    class Dispatch {		static public function request( $request ) {	    	    $controller_directory = 'app/controllers/';	    	    if ( isset($request['params']) ) {				$params = $request['params'];			    }	    	    $class = ucfirst(strtolower( $request['class'] ));	    $method = strtolower( $request['method'] );	    	    if( $class == "Applications" ) {				$class = ucfirst($method);		$method = $params;		$params = $options;				if( empty($method) ) {		    		    $method = 'main';		    		}			    }	    	    $class .= '_Controller';	    	    if( file_exists($controller_directory.$class. '.php') ) {				include_once($controller_directory.'/Controller.php');		include_once($controller_directory.$class. '.php');				$c = new $class;				if( method_exists($c, $method) ) {		    		    $c->$method($params);		    		} else {		    		    throw new DispatchException('Unable to find method: '. $method .' of class: '. $class);		    		}				if( method_exists($c, 'render') ) {		    		    $c->render();		    		} else {		    		    throw new DispatchException('Unable to find method: render of class: '. $class);		    		}			    } else {				throw new DispatchException('Unable to find controller: '. $controller_directory.$class .'.php');			    }	    	}	    }?>