public function isValid($value, $context = null)
 {
     $this->_messages = array();
     if (!is_string($value)) {
         $message = $this->_createMessage(self::ERROR_INVALID_TYPE, $value);
         $this->_messages[self::ERROR_INVALID_TYPE] = $message;
         return false;
     }
     if (!isset($context['lifeCycleId']) || !$context['lifeCycleId']) {
         $message = $this->_createMessage(self::ERROR_LIFECYCLE_NOT_DEFINED, $value);
         $this->_messages[self::ERROR_LIFECYCLE_NOT_DEFINED] = $message;
         return false;
     }
     $lifeCycleId = $context['lifeCycleId'];
     $service = TariffPlanService::getInstance();
     try {
         $item = $service->load(TariffPlanService::TYPE_LIFECYCLE, $value, $lifeCycleId);
     } catch (Application\Exceptions\GlobalServiceException $e) {
         $message = $this->_createMessage(self::ERROR_ON_CONNECTION, $value);
         $this->_messages[self::ERROR_ON_CONNECTION] = $message;
         return false;
     }
     if (!isset($item)) {
         $message = $this->_createMessage(self::ERROR_TARIFFPLAN_LIFECYCLE_NOT_FOUND, $value);
         $this->_messages[self::ERROR_TARIFFPLAN_LIFECYCLE_NOT_FOUND] = $message;
         return false;
     }
     return true;
 }
 public function init()
 {
     $this->_spSrv = ServicePackService::getInstance();
     $this->_lifeCycleSrv = LifeCycleService::getInstance();
     $this->_restrictionsSrv = RestrictionService::getInstance();
     $this->_tariffSrv = TariffPlanService::getInstance();
     $this->_orgSrv = \Application\Service\OrgService::getInstance();
 }
 public function init()
 {
     $this->_spSrv = ServicePackService::getInstance();
     $this->_lifeCycleSrv = LifeCycleService::getInstance();
     $this->_restrictionsSrv = RestrictionService::getInstance();
     $this->_tariffSrv = TariffPlanService::getInstance();
     $this->_steeringListSrv = SteeringListService::getInstance();
 }
 public function isValid($value)
 {
     $this->_messages = array();
     if (!is_string($value)) {
         $message = $this->_createMessage(self::ERROR_INVALID_TYPE, $value);
         $this->_messages[self::ERROR_INVALID_TYPE] = $message;
         return false;
     }
     $service = TariffPlanService::getInstance();
     try {
         $item = $service->load(TariffPlanService::TYPE_SERVICES, $value);
     } catch (Application\Exceptions\GlobalServiceException $e) {
         $message = $this->_createMessage(self::ERROR_ON_CONNECTION, $value);
         $this->_messages[self::ERROR_ON_CONNECTION] = $message;
         return false;
     }
     if (!isset($item)) {
         $message = $this->_createMessage(self::ERROR_TARIFFPLAN_SERVICES_NOT_FOUND, $value);
         $this->_messages[self::ERROR_TARIFFPLAN_SERVICES_NOT_FOUND] = $message;
         return false;
     }
     return true;
 }
 public function setUp()
 {
     $this->_service = TariffPlanService::getInstance();
 }
 public function init()
 {
     $this->_tariffPlanSrv = \Application\Service\TariffPlanService::getInstance();
     $this->_servicePackSrv = \Application\Service\ServicePackService::getInstance();
 }
 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;
 }