Index.php (Controller)
<?php
class Index extends Controller {
/**
* The index action, main action of the controller
*/
public function IndexAction() {
$data = array('firstName' => 'Allard', 'lastName' => 'Jansen' );
$this->render('Index.phtml', $data);
}
/**
* The index action, main action of the controller
*/
public function ContactAction() {
$this->render('Contact.phtml');
}
}
?>
Controller.php
<?php
class Controller extends View {
}
?>
View.php
<?php
class View {
public $_content;
/**
* Render the controller around the view
*
* @param type $fileName string
* @param type $data array
*/
public function render( $fileName, $data = null ) {
if( is_array($data) ) {
extract($data);
}
ob_start();
require 'Views/' . get_called_class() . '/' . $fileName;
$this->_content = ob_get_contents();
ob_end_clean();
require 'Views/Layout.phtml';
}
}
?>