00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00016 abstract class EditorController extends BaseEditor
00017 {
00018 public function __construct(Prototyped $subject)
00019 {
00020 $this->commandMap['import'] = new ImportCommand();
00021 $this->commandMap['drop'] = new DropCommand();
00022 $this->commandMap['save'] = new SaveCommand();
00023 $this->commandMap['edit'] = new EditCommand();
00024 $this->commandMap['add'] = new AddCommand();
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->commandMap[$command]->run(
00043 $this->subject, $form, $request
00044 );
00045 } else
00046 $mav = ModelAndView::create();
00047
00048 return $this->postHandleRequest($mav, $request);
00049 }
00050 }
00051 ?>