コード例 #1
0
 public function delete($id)
 {
     if (!($id instanceof SupplServicesModel || is_string($id))) {
         throw new InvalidArgumentException("Invalid model. Not an supplementary service");
     }
     return parent::delete($id);
 }
コード例 #2
0
 protected function _getItem()
 {
     $itemId = $this->getRequest()->getParam('id');
     $item = $this->_service->load($itemId);
     if (empty($item)) {
         throw new NotFoundException($this->_getName() . ' ' . $itemId . ' not found', 404);
     }
     $this->_helper->allowed('read', $item);
     return $item;
 }
コード例 #3
0
 public function delete($idOrModel)
 {
     if ($idOrModel instanceof models\ModelAbstract) {
         $model = $idOrModel;
     } else {
         $model = $this->load($idOrModel);
     }
     $result = parent::delete($model);
     WatcherService::getInstance()->removeByScope('apiId', $model->id);
 }
コード例 #4
0
 public function delete($supervGroup)
 {
     $count = $this->countSims($supervGroup);
     if ($count > 0) {
         throw new ValidateException("Supervision group is not empty (has {$count} sims)");
     }
     if (strtolower($supervGroup->id) == 'default_group') {
         throw new ValidateException("It not possible remove default supervision group");
     }
     return parent::delete($supervGroup);
 }
コード例 #5
0
 /**
  * Delete one model
  *
  * @param  string|ModelAbstract $idOrModel
  * @return boolean
  */
 public function delete($idOrModel)
 {
     if ($idOrModel instanceof ModelAbstract) {
         $model = $idOrModel;
     } else {
         $model = $this->load($idOrModel);
     }
     $result = parent::delete($model);
     $this->_sendEvent('delete', $model);
     return $result;
 }
コード例 #6
0
 /**
  * @param  TemplateModel $template
  * @return TemplateModel
  */
 public function create(ModelAbstract $template, $org = null)
 {
     if ($template->getId()) {
         throw new InvalidArgumentException('Supplied template model already has an Id');
     }
     if (!$template->getType()) {
         throw new InvalidArgumentException('Supplied template model needs a type');
     }
     if (!$org) {
         $org = \App::getOrgUserLogged();
     }
     $template->setOrganizationId($org->getId());
     return parent::create($template);
 }
コード例 #7
0
 public function delete($commercialGroup)
 {
     if (is_string($commercialGroup)) {
         $commercialGroup = new CommercialGroupModel(array('id' => $commercialGroup));
     }
     if (!$commercialGroup instanceof CommercialGroupModel) {
         throw new AppEx\InvalidArgumentException('No supplied commericial group Id or model');
     }
     if (is_null($commercialGroup->getSubscriberCount())) {
         $commercialGroup = $this->load($commercialGroup->getId());
     }
     if ($commercialGroup->getSubscriberCount() !== 0) {
         throw new AppEx\InvalidArgumentException('Supplied commericial group has subscriptions');
     }
     return parent::delete($commercialGroup);
 }
コード例 #8
0
 public function create(ModelAbstract $model)
 {
     if (!$model instanceof WatcherModel) {
         throw new InvalidArgumentException("Watcher model expected");
     }
     if (!$model->status) {
         $model->status = WatcherModel::STATUS_ACTIVE;
     }
     if (!$model->priority) {
         $model->priority = WatcherModel::PRIORITY_LOW;
     }
     if (is_null($model->tags)) {
         $model->tags = array();
     }
     $model->eventCount = 0;
     $model->eventList = array();
     $result = parent::create($model);
     \App::log()->info("{WATCHERS}{PUSH} Created new Watcher (ID: {$model->id}) for {$model->entityType}: " . implode(', ', $model->entityIds));
     return $result;
 }
コード例 #9
0
 /**
  * @param  string $id
  * @return void
  */
 public function delete($idOrModel)
 {
     if ($idOrModel instanceof DownloadTokenModel) {
         $downloadToken = $idOrModel;
     } else {
         $downloadToken = $this->load($idOrModel);
     }
     return parent::delete($downloadToken);
 }
コード例 #10
0
 protected function _validateLteState($state)
 {
     $validator = new \Zend_Validate_InArray(array('true', 'false', '1', '0'));
     if (!$validator->isValid($state)) {
         AbstractService::throwValidateException($validator->getMessages(), ValidationCodes::INVALID_VALUE, 'lte');
     }
 }
コード例 #11
0
 public function update(ModelAbstract $model)
 {
     $model->userId = \App::getUserLogged()->id;
     return parent::update($model);
 }
コード例 #12
0
ファイル: ProductService.php プロジェクト: phox/xsale
 public function getPaginator()
 {
     return parent::getPaginator('SELECT o FROM Application\\Entity\\Product o');
 }
コード例 #13
0
ファイル: SaleRecordService.php プロジェクト: phox/xsale
 public function getPaginator()
 {
     return parent::getPaginator('SELECT o,c FROM Application\\Entity\\Order o LEFT JOIN o.customer c');
 }
コード例 #14
0
ファイル: StockRecordService.php プロジェクト: phox/xsale
 public function getPaginator()
 {
     return parent::getPaginator('SELECT o FROM Application\\Entity\\StockRecord o');
 }
コード例 #15
0
 public function validate($model, $exceptions = false, ModelAbstractValidate $validator = null, $removeNotPresentFields = false)
 {
     if (!$validator) {
         if ($model instanceof TariffPlanLifeCycleModel) {
             $validator = new \Application\Model\Validate\TariffPlanLifeCycleValidate();
         } else {
             if ($model instanceof TariffPlanServicesModel) {
                 $validator = new \Application\Model\Validate\TariffPlanServicesValidate();
             } else {
                 return array('Model' => "Data must be a tariff.");
             }
         }
     }
     return parent::validate($model, $exceptions, $validator, $removeNotPresentFields);
 }
コード例 #16
0
ファイル: Pergunta.php プロジェクト: thiagomariano/enquetexys
 public function __construct(EntityManager $em)
 {
     parent::__construct($em);
     $this->entity = "Application\\Entity\\Pergunta";
 }
コード例 #17
0
 /**
  * @param AbstractService $service
  * @return AbstractService
  */
 protected function getService(AbstractService $service)
 {
     $service->setEntityManager($this->em);
     $service->setConfig($this->config);
     return $service;
 }
コード例 #18
0
 public function __construct(EntityManager $em)
 {
     $this->entity = "Application\\Entity\\Food";
     parent::__construct($em);
 }
コード例 #19
0
 public function delete($model)
 {
     if (is_string($model)) {
         $model = $this->load($model);
     }
     if (!$model instanceof ServicePackModel) {
         throw new AppEx\InvalidArgumentException('Supplied service pack model must have Id');
     }
     if ($model->getCustomerCount() !== 0) {
         throw new AppEx\ForbiddenException('Delete service pack assigned to a customer is not allowed.');
     }
     $result = parent::delete($model);
     if ($model->getLifeCycleId()) {
         try {
             LifeCycleService::getInstance()->delete($model->getLifeCycleId());
         } catch (\Exception $e) {
             \App::log()->warn($e);
         }
     }
     if ($model->getRestrictionsId()) {
         try {
             RestrictionService::getInstance()->delete($model->getRestrictionsId());
         } catch (\Exception $e) {
             \App::log()->warn($e);
         }
     }
     if ($model->getTariffPlanLifeCycleId()) {
         try {
             TariffPlanService::getInstance()->delete($model->getTariffPlanLifeCycleId(), TariffPlanService::TYPE_LIFECYCLE);
         } catch (\Exception $e) {
             \App::log()->warn($e);
         }
     }
     if ($model->getTariffPlanServicesId()) {
         try {
             TariffPlanService::getInstance()->delete($model->getTariffPlanServicesId(), TariffPlanService::TYPE_SERVICES);
         } catch (\Exception $e) {
             \App::log()->warn($e);
         }
     }
     $steeringListService = SteeringListService::getInstance();
     if ($steeringList = $steeringListService->loadByServicePack($model->id)) {
         $steeringListService->delete($steeringList);
     }
     return true;
 }