*/ class mpWebController { /** * The used view object. * * @type mpWebView * @var mpWebView $view */ private $view = null; /** * The controller ctor. */ public function __construct() { $this->view = new mpWebView(); $this->view->connect( "clicked", array( $this, "doAddProduct" ) ); } /** * Starts the controller process. */ public function run() { $this->view->show(); } /** * Add product action with the hole domain logic. */ public function doAddProduct() { $name = $this->view->getText(); // Create a domain Facade $facade = new mpDomainFacade(); try { // Try to add product $facade->addProduct( $name ); // Reset input $this->view->setText( "" ); } catch ( mpDomainException $e ) { $this->showDialog( $e->getTitle(), $e->getMessage() ); } } /** * Shows a simple error dialog. * * @param string $title * @param string $message */ private function showDialog( $title, $message ) { printf( ' ', $title, $message ); } } $controller = new mpWebController(); $controller->run();