public static function convertCompanyServiceToArray(ICompanyService $company_service)
 {
     $res = array();
     //header
     $res['id'] = $company_service->getIdentifier();
     $res['name'] = $company_service->getName();
     $res['overview'] = $company_service->getOverview();
     $res['call_2_action_uri'] = $company_service->getCall2ActionUri();
     $res['active'] = $company_service->isActive();
     $company = $company_service->getCompany();
     if ($company) {
         $res['company_id'] = $company->getIdentifier();
     }
     //resources
     $additional_resources = array();
     foreach ($company_service->getResources() as $resource) {
         array_push($additional_resources, CompanyServiceAssembler::convertResource2Array($resource));
     }
     $res['additional_resources'] = $additional_resources;
     //videos
     $videos = array();
     foreach ($company_service->getVideos() as $video) {
         array_push($videos, MarketPlaceAssembler::convertVideo2Array($video));
     }
     $res['videos'] = $videos;
     //draft
     if ($company_service->isDraft()) {
         $res['live_service_id'] = $company_service->getLiveServiceId();
     }
     return $res;
 }
 /**
  * @param ICompanyService $company_service
  * @throws EntityAlreadyExistsException
  * @throws PolicyException
  * @return int
  */
 public function register(ICompanyService &$company_service)
 {
     $repository = $this->repository;
     if (!is_null($this->add_policy)) {
         $this->add_policy->canAdd($company_service->getCompany());
     }
     $query = new QueryObject($company_service);
     $query->addAndCondition(QueryCriteria::equal('Name', $company_service->getName()));
     $query->addAndCondition(QueryCriteria::equal('Company.ID', $company_service->getCompany()->getIdentifier()));
     $res = $repository->getBy($query);
     if ($res) {
         throw new EntityAlreadyExistsException('CompanyService', sprintf('name %s', $company_service->getName()));
     }
     return $repository->add($company_service);
 }