Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class collectionPhrasesDTO
- {
- private $phrasesDTO = array();
- public function addPhraseDTO(virtualPhraseDTO $phraseDTO)
- {
- $this->phrasesDTO[] = $phraseDTO;
- }
- public function toArray()
- {
- return $this->phrasesDTO;
- }
- public function toStructuredAdsArray()
- {
- $ads = array();
- foreach ($this->toArray() as $phraseDTO)
- {
- $phraseParams = $phraseDTO->getParams();
- $adId = $phraseParams->adId;
- if (!isset($ads[$adId]))
- {
- $ads[$adId] = $phraseDTO->getAdInfo();
- $ads[$adId]->additionalInfo = $phraseDTO->getAdAdditinoalInfo();
- $ads[$adId]->phrases = array();
- }
- $ads[$adId]->phrases[] = $phraseParams->sharedParams;
- }
- return $ads;
- }
- public function toBundleAdInfo()
- {
- $bundleAdInfo = new bundleAdInfo();
- $structuredAds = $this->toStructuredAdsArray();
- foreach ($structuredAds as $adInfo)
- {
- $bundleAdInfo->addAdditionalInfo($adInfo->additionalInfo);
- foreach ($adInfo->phrases as $phraseSharedParams)
- {
- $bundleAdInfo->addPhrasesSharedParams($phraseSharedParams);
- }
- }
- return $bundleAdInfo;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement