Created
March 13, 2009 19:32
-
-
Save henrikbjorn/78724 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Abstract class to do some preconfiguration for all controllers | |
* extending this one. | |
* | |
* @package BaseApp | |
*/ | |
abstract class Template_Controller extends Controller | |
{ | |
protected $Session; | |
protected $View; | |
protected $Render = TRUE; | |
protected $Layout = 'default'; | |
/** | |
* Does some standard app specific loading | |
**/ | |
public function __construct() | |
{ | |
parent::__construct(); | |
//Loads the session module | |
$this->Layout = new View('layouts/' . $this->Layout); | |
//generate controller path for views | |
$path = strtolower(substr(__CLASS__, 0, -11)) . '/' . Router::$method; | |
$this->View = new View($path); | |
//Hook | |
Event::add('system.post_controller', array($this, '__render')); | |
} | |
/** | |
* Handles template render etc | |
*/ | |
public function __render() | |
{ | |
if ($this->Render) { | |
$this->Layout->content = $this->View; | |
$this->Layout->render(TRUE); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment