/** * Si existe un dueño de local loqueado le muestro formulario de alta de local, sino redirijo a myaccount * @return type */ public function addAction() { if ($user = $this->checkPermiso()) { // Es dueño. tiene acceso a agregar local $form = new LocalForm(); $form->get('ID_DUENO')->setValue($user->uid); if ($this->getRequest()->isPost()) { $shop = new GLocal(); //$form->setInputFilter($shop->getInputFilter()); $form->setData($this->getRequest()->getPost()); if ($form->isValid()) { // Formulario válido $shop->exchangeArray($form->getData()); $utils = $this->getServiceLocator()->get('LocalUtils'); $utils->saveLocal($shop); $this->addInfoMessage(GeneralMessages::SHOP_ADD_OK); return $this->redirect()->toRoute('myaccount/shop'); } else { // Formulario invalido $this->addErrorMessage(GeneralMessages::FORM_ERROR); return $this->redirect()->toRoute('myaccount/shop', array('action' => 'add')); } } $config = $this->getServiceLocator()->get('Config'); $gmapDefaultConfig = $config['GMap']; return array('form' => $form, 'api_key' => $gmapDefaultConfig['api_key']); } else { return $this->redirect()->toRoute('myaccount'); } }
public function saveLocal(GLocal $local) { if ($local->status == null) { $local->status = GLocalTable::DEFAULT_LOCAL_STATUS; } if ($local->lid == 0) { $this->tableGateway->insert($local->getFullData()); } else { if ($this->getLocal($local->lid)) { $this->tableGateway->update($local->getFullData(), array('LID' => $local->lid)); } else { //throw new \Exception('Form id does not exist'); return null; } } }
public static function getTableIO($adapter) { return new GLocalTable(GLocal::getTableGateway($adapter)); }