00001 <?php 00002 /*************************************************************************** 00003 * Copyright (C) 2006-2008 by Anton E. Lebedevich * 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 00015 abstract class EditorController extends BaseEditor 00016 { 00017 public function __construct(Prototyped $subject) 00018 { 00019 $this->commandMap['import'] = new ImportCommand(); 00020 $this->commandMap['drop'] = new DropCommand(); 00021 $this->commandMap['save'] = new SaveCommand(); 00022 $this->commandMap['edit'] = new EditCommand(); 00023 $this->commandMap['add'] = new AddCommand(); 00024 00025 parent::__construct($subject); 00026 } 00027 00031 public function handleRequest(HttpRequest $request) 00032 { 00033 $this->map->import($request); 00034 00035 $form = $this->getForm(); 00036 00037 if (!$command = $form->getValue('action')) 00038 $command = $form->get('action')->getDefault(); 00039 00040 if ($command) { 00041 $mav = $this->commandMap[$command]->run( 00042 $this->subject, $form, $request 00043 ); 00044 } else 00045 $mav = ModelAndView::create(); 00046 00047 return $this->postHandleRequest($mav, $request); 00048 } 00049 } 00050 ?>