arse/includes/core/controller.inc.php
Emmanuel BENOîT 871d28cd16 Importing bits and pieces
This is the initial import based on a few files I had around.
2012-02-05 12:56:54 +01:00

44 lines
771 B
PHP

<?php
class ParameterException extends Exception { }
abstract class Controller
{
protected final function getParameter( $name , $method = null )
{
if ( $method === null ) {
try {
return $this->getParameter( $name , 'POST' );
} catch ( ParameterException $e ) {
return $this->getParameter( $name , 'GET' );
}
}
$from = '_' . $method;
global $$from;
if ( ! array_key_exists( $name , $$from ) ) {
throw new ParameterException( "$name/$method" );
}
return ${$from}[ $name ];
}
public abstract function handle( Page $page );
}
final class Ctrl_Simple
extends Controller
{
private $view;
public function __construct( View $view )
{
$this->view = $view;
}
public function handle( Page $page )
{
return $this->view;
}
}