region_repository = $region_repository; $this->support_channel_type_repository = $support_channel_type_repository; } protected function clearCollections(ICompanyService &$regional_supported_company_service){ parent::clearCollections($regional_supported_company_service); $regional_supported_company_service->clearRegionalSupports(); } protected function updateCollections(ICompanyService &$regional_supported_company_service, array $data){ 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); } } } protected function addRegionalSupport(array $regional_support_data, IRegionalSupportedCompanyService $regional_supported_company_service){ $region = $this->marketplace_factory->buildRegionById(intval($regional_support_data['region_id'])); $support_channels_data = $regional_support_data['support_channels']; $regional_support = $this->factory->buildRegionalSupport($region,$regional_supported_company_service); $region = $this->region_repository->getById($regional_support->getRegion()->getIdentifier()); if(!$region) throw new NotFoundEntityException('',''); foreach($regional_support->getSupportChannelTypes() as $support_channel_type){ if(!$this->support_channel_type_repository->getById($support_channel_type->getIdentifier())) throw new NotFoundEntityException('',''); } $regional_supported_company_service->addRegionalSupport($regional_support); foreach($support_channels_data as $support_channel_data){ $support_channel_type = $this->marketplace_factory->buildSupportChannelTypeById(intval($support_channel_data['type_id'])); $regional_support->addSupportChannelType($support_channel_type,$support_channel_data['data']); } } }