예제 #1
0
파일: Service.php 프로젝트: knatorski/SMS
 /**
  * Utworzenie nowej usługi lub nadpis poprzedniej (o ile podano id usługi)
  * @param array $data
  * @throws Logic_Exception
  */
 public function createOrUpdateService(array $data, $idService = null)
 {
     if (null === $idService) {
         $row = $this->getModel()->createRow($data);
     } else {
         $row = $this->getService($idService);
         $row->setFromArray($data);
     }
     try {
         $idService = $row->save();
     } catch (Exception $e) {
         throw new Logic_Exception("Cannot save basic service data!", 0, $e);
     }
     if ($this->_model->getName() == 'service_sms' && !empty($data['mask'])) {
         $maskModel = new WsServiceSmsMask();
         $maskModel->setMasksForService($idService, $data['mask']);
     }
     return $idService;
 }