00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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 ?>