MonolithicController.class.php

Go to the documentation of this file.
00001 <?php
00002 /****************************************************************************
00003  *   Copyright (C) 2006-2007 by Anton E. Lebedevich, Konstantin V. Arkhipov *
00004  *                                                                          *
00005  *   This program is free software; you can redistribute it and/or modify   *
00006  *   it under the terms of the GNU Lesser General Public License as         *
00007  *   published by the Free Software Foundation; either version 3 of the     *
00008  *   License, or (at your option) any later version.                        *
00009  *                                                                          *
00010  ****************************************************************************/
00011 /* $Id: MonolithicController.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012     
00016     abstract class MonolithicController extends BaseEditor
00017     {
00018         public function __construct(Prototyped $subject)
00019         {
00020             $this->commandMap['import'] = 'doImport';
00021             $this->commandMap['drop']   = 'doDrop';
00022             $this->commandMap['save']   = 'doSave';
00023             $this->commandMap['edit']   = 'doEdit';
00024             $this->commandMap['add']    = 'doAdd';
00025             
00026             parent::__construct($subject);
00027         }
00028         
00032         public function handleRequest(HttpRequest $request)
00033         {
00034             $this->map->import($request);
00035             
00036             $form = $this->map->getForm();
00037             
00038             if (!$command = $form->getValue('action'))
00039                 $command = $form->get('action')->getDefault();
00040             
00041             if ($command) {
00042                 $mav = $this->{$this->commandMap[$command]}(
00043                     $this->subject, $form, $request
00044                 );
00045             } else
00046                 $mav = ModelAndView::create();
00047             
00048             return parent::postHandleRequest($mav, $request);
00049         }
00050         
00054         public function doImport(
00055             Prototyped $subject, Form $form, HttpRequest $request
00056         )
00057         {
00058             return ImportCommand::create()->run($subject, $form, $request);
00059         }
00060         
00064         public function doDrop(
00065             Prototyped $subject, Form $form, HttpRequest $request
00066         )
00067         {
00068             return DropCommand::create()->run($subject, $form, $request);
00069         }
00070         
00074         public function doSave(
00075             Prototyped $subject, Form $form, HttpRequest $request
00076         )
00077         {
00078             return SaveCommand::create()->run($subject, $form, $request);
00079         }
00080         
00084         public function doEdit(
00085             Prototyped $subject, Form $form, HttpRequest $request
00086         )
00087         {
00088             return EditCommand::create()->run($subject, $form, $request);
00089         }
00090         
00094         public function doAdd(
00095             Prototyped $subject, Form $form, HttpRequest $request
00096         )
00097         {
00098             return AddCommand::create()->run($subject, $form, $request);
00099         }
00100     }
00101 ?>

Generated on Sun Dec 9 21:56:24 2007 for onPHP by  doxygen 1.5.4