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 addAction()
 {
     $type = (int) $this->params()->fromRoute('type', CertificateFactory::NORMAL_TYPE);
     $form = CertificateFactory::createCertificateForm($type);
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $certificate = CertificateFactory::createCertificate($type);
         $form->setupInputFilter();
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $certificate->exchangeArray($form->getData());
             $this->getCertificatesTable()->save($certificate);
             $this->getPriceHistoryTable()->save($certificate->ISIN, $certificate->currentPrice);
             return $this->redirect()->toRoute('home');
         }
     }
     return array('form' => $form, 'type' => $type);
 }