Importing bits and pieces

This is the initial import based on a few files I had around.
This commit is contained in:
Emmanuel BENOîT 2012-02-05 12:56:54 +01:00
commit 871d28cd16
20 changed files with 1994 additions and 0 deletions
includes/core

View file

@ -0,0 +1,44 @@
<?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;
}
}