public function get($ISIN) { $rowset = $this->tableGateway->select(array('ISIN' => $ISIN)); $row = $rowset->current(); if (!$row) { return null; } $certificate = CertificateFactory::createCertificate($row->type); $certificate->exchangeArray($row); return $certificate; }
public function editAction() { $certificate = $this->getCertificateFromRoute(); if (!$certificate) { return $this->redirect()->toRoute('home'); } $form = CertificateFactory::createCertificateForm($certificate->getType()); $ISIN = $certificate->ISIN; $form->bind($certificate); $form->get('submit')->setValue('Edit'); $request = $this->getRequest(); if ($request->isPost()) { $form->setupInputFilter(); $form->setData($request->getPost()); if ($form->isValid()) { $this->getCertificatesTable()->save($certificate); $this->getPriceHistoryTable()->save($certificate->ISIN, $certificate->currentPrice); return $this->redirect()->toRoute('home'); } } return array('form' => $form, 'type' => $certificate->getType(), 'ISIN' => $ISIN); }