66 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			66 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| 	/**
 | |
| 	 * PanaceaPageController
 | |
| 	 *
 | |
| 	 * @package Panacea
 | |
| 	 * @author  Tommy Montgomery
 | |
| 	 * @since   2008-10-05
 | |
| 	 */
 | |
| 	
 | |
| 	/** Bootstraps the NowhereConcave framework */
 | |
| 	require_once 'NowhereConcave/bootstrap.php';
 | |
| 	
 | |
| 	/**
 | |
| 	 * Panacea page controller
 | |
| 	 *
 | |
| 	 * @package Panacea
 | |
| 	 * @author  Tommy Montgomery
 | |
| 	 * @since   2008-10-05
 | |
| 	 */
 | |
| 	class PanaceaPageController extends Controller {
 | |
| 		
 | |
| 		/**
 | |
| 		 * Creates a new {@link Controller}
 | |
| 		 *
 | |
| 		 * @author Tommy Montgomery
 | |
| 		 * @since  2008-10-05
 | |
| 		 * @uses   PanaceaViewFactory::getInstance()
 | |
| 		 *
 | |
| 		 * @param  string $page     Name of the page (view)
 | |
| 		 * @param  int    $viewType One of the {@link View}<kbd>::VIEWTYPE_*</kbd> constants
 | |
| 		 * @throws {@link InvalidTypeException}
 | |
| 		 */
 | |
| 		public function __construct($page = '', $viewType = View::VIEWTYPE_HTML) {
 | |
| 			parent::__construct($page, $viewType);
 | |
| 			$this->viewFactory = PanaceaViewFactory::getInstance();
 | |
| 		}
 | |
| 		
 | |
| 		/**
 | |
| 		 * Handles the specified request, and generates a
 | |
| 		 * suitable response
 | |
| 		 *
 | |
| 		 * @author Tommy Montgomery
 | |
| 		 * @since  2008-10-05
 | |
| 		 * @uses   Request::create()
 | |
| 		 * @uses   HttpUtil::getRequestMethod()
 | |
| 		 *
 | |
| 		 * @throws {@link InvalidRequestException} if a {@link View} cannot be created
 | |
| 		 * @return View
 | |
| 		 */
 | |
| 		public function handleRequest(Request $request = null) {
 | |
| 			if (!($request instanceof Request)) {
 | |
| 				$request = Request::create(HttpUtil::getRequestMethod());
 | |
| 			}
 | |
| 			
 | |
| 			try {
 | |
| 				return $this->viewFactory->getView($this->page, $request->__toString());
 | |
| 			}
 | |
| 			catch (ClassNotFoundException $e) {
 | |
| 				throw new InvalidRequestException($request);
 | |
| 			}
 | |
| 		}
 | |
| 		
 | |
| 	}
 | |
| 
 | |
| ?>
 |