예제 #1
0
 /**
  * Сохранить
  * 
  * @param \Application_Model_Currency $currency Модель currency
  */
 public function save(Application_Model_Currency $currency)
 {
     $data = ['title' => $currency->getTitle(), 'name' => $currency->getName(), 'providerCurrencyId' => $currency->getProviderCurrencyId()];
     if (null === ($id = $currency->getId())) {
         unset($data['id']);
         $this->getDbTable()->insert($data);
     } else {
         $this->getDbTable()->update($data, ['id = ?' => $id]);
     }
 }
예제 #2
0
파일: Abstract.php 프로젝트: belyakovaAA/ca
 /**
  * Добавить валюту по значению буквенного кода
  * 
  * @param string $currencyLetterCode буквенный код валюты
  * @return string
  */
 public function addCurrency($currencyLetterCode)
 {
     $currencyMapper = new Application_Model_CurrencyMapper();
     $existsCurrency = $currencyMapper->fetchByName($currencyLetterCode);
     if ($existsCurrency) {
         return 'exists';
     }
     $currencyModel = new Application_Model_Currency();
     $quotations = $this->_prepareData();
     foreach ($quotations as $data) {
         if ($data['name'] !== $currencyLetterCode) {
             continue;
         }
         $currencyModel->setOptions($data);
         break;
     }
     if (!$currencyModel->getProviderCurrencyId()) {
         return 'notFound';
     }
     $currencyMapper->save($currencyModel);
     $result = $this->updateQuotations();
     return $result;
 }