Importing bits and pieces
This is the initial import based on a few files I had around.
This commit is contained in:
commit
871d28cd16
20 changed files with 1994 additions and 0 deletions
includes/core
44
includes/core/controller.inc.php
Normal file
44
includes/core/controller.inc.php
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue