Skip to content

Instantly share code, notes, and snippets.

@henrikbjorn
Created March 13, 2009 19:32
Show Gist options
  • Save henrikbjorn/78724 to your computer and use it in GitHub Desktop.
Save henrikbjorn/78724 to your computer and use it in GitHub Desktop.
<?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