Location: PHPKode > projects > DIY Blog > diy-blog/classes/diy-blog/backend/controller/BackEndController.class.php
<?php

/**
 * Handles requests to the backend application.
 * @package diy-blog.backend.controller
 * @author	Martynas Jusevicius <hide@address.com>
 * @link	http://www.xml.lt
 */

class BackEndController extends Controller
{
	private static $instance = null;

	private function __construct() {}
	private function __clone() {}

	public static function getInstance()
	{
		if (self::$instance == null) self::$instance = new self();
		return self::$instance;
	}

	public function process(Request $request, Response $response, ResourceMapping $mapping)
	{
		try
		{
			// these 2 cannot be in BackEndResource since they should also work with NotFoundView, which means no resource was found
			if ($request->getSession()->getAttribute("user") == null) $request->getSession()->setAttribute("user", new GuestUser());
			if ($request->getParameter("action") == "logout") $request->getSession()->setAttribute("user", new GuestUser());

			parent::process($request, $response, $mapping);

			if ($this->resource == null) $this->view = new NotFoundView(null);

			if ($this->view != null) $this->view->display($request, $response);
			$this->output($response);
		}
		catch (Exception $e)
		{
			//print $e->getMessage();
			$this->view = new ErrorView(null);
			$request->setAttribute("error-message", $e->getMessage());
			$this->view->display($request, $response);
			$this->output($response);
		}

	}

}

?>
Return current item: DIY Blog