public function delete($id)
 {
     if (!($id instanceof SupplServicesModel || is_string($id))) {
         throw new InvalidArgumentException("Invalid model. Not an supplementary service");
     }
     return parent::delete($id);
 }
 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;
 }
Ejemplo n.º 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);
 }
 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);
 }
 /**
  * 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;
 }
Ejemplo n.º 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);
 }
 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);
 }
Ejemplo n.º 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;
 }
 /**
  * @param  string $id
  * @return void
  */
 public function delete($idOrModel)
 {
     if ($idOrModel instanceof DownloadTokenModel) {
         $downloadToken = $idOrModel;
     } else {
         $downloadToken = $this->load($idOrModel);
     }
     return parent::delete($downloadToken);
 }
Ejemplo n.º 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');
     }
 }
 public function update(ModelAbstract $model)
 {
     $model->userId = \App::getUserLogged()->id;
     return parent::update($model);
 }
Ejemplo n.º 12
0
 public function getPaginator()
 {
     return parent::getPaginator('SELECT o FROM Application\\Entity\\Product o');
 }
Ejemplo n.º 13
0
 public function getPaginator()
 {
     return parent::getPaginator('SELECT o,c FROM Application\\Entity\\Order o LEFT JOIN o.customer c');
 }
Ejemplo n.º 14
0
 public function getPaginator()
 {
     return parent::getPaginator('SELECT o FROM Application\\Entity\\StockRecord o');
 }
 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);
 }
Ejemplo n.º 16
0
 public function __construct(EntityManager $em)
 {
     parent::__construct($em);
     $this->entity = "Application\\Entity\\Pergunta";
 }
Ejemplo n.º 17
0
 /**
  * @param AbstractService $service
  * @return AbstractService
  */
 protected function getService(AbstractService $service)
 {
     $service->setEntityManager($this->em);
     $service->setConfig($this->config);
     return $service;
 }
 public function __construct(EntityManager $em)
 {
     $this->entity = "Application\\Entity\\Food";
     parent::__construct($em);
 }
 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;
 }