protected function updateCollections(ICompanyService $regional_supported_company_service, array $data)
 {
     $regional_supported_company_service = parent::updateCollections($regional_supported_company_service, $data);
     //add regional support
     if (array_key_exists('regional_support', $data) && is_array($data['regional_support'])) {
         $regional_supports_data = $data['regional_support'];
         foreach ($regional_supports_data as $regional_support_data) {
             $this->addRegionalSupport($regional_support_data, $regional_supported_company_service);
         }
     }
     return $regional_supported_company_service;
 }
 /**
  * @return SS_HTTPResponse
  */
 public function publishCompanyService()
 {
     try {
         $company_service_live_id = intval($this->request->param('COMPANY_SERVICE_ID'));
         $data = $this->getJsonRequest();
         if (!$data) {
             return $this->serverError();
         }
         //save the live version
         if ($company_service_live_id == 0) {
             // this means is a draft without a live version yet
             $data['live_service_id'] = $this->manager->addCompanyService($data)->getIdentifier();
             //save the draft
             if ($data['id']) {
                 //it could be that the draft was never saved yet, in that case id should be 0
                 $this->draft_manager->updateCompanyService($data);
             } else {
                 $this->draft_manager->addCompanyService($data);
             }
         } else {
             //if there is a live version of this draft, update it
             $this->draft_manager->updateCompanyService($data);
             $data['id'] = $data['live_service_id'];
             $this->manager->updateCompanyService($data);
         }
         return $this->published();
     } catch (EntityAlreadyExistsException $ex1) {
         SS_Log::log($ex1, SS_Log::ERR);
         return $this->addingDuplicate($ex1->getMessage());
     } catch (PolicyException $ex2) {
         SS_Log::log($ex2, SS_Log::ERR);
         return $this->validationError($ex2->getMessage());
     } catch (EntityValidationException $ex3) {
         SS_Log::log($ex3, SS_Log::ERR);
         return $this->validationError($ex3->getMessages());
     }
 }
 public function register(ICompanyService &$training)
 {
     $training->setMarketplace($this->getMarketPlaceType());
     return parent::register($training);
 }