Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function replace($id, ItemInterface $item)
 {
     if ($this->has($id)) {
         $this->items[$id] = $item;
     } else {
         throw new \DomainException(sprintf('Failed replacing item "%s": item does not exist.', $item->getId()));
     }
 }
 /**
  * @param ItemInterface $item
  */
 public function addItem(ItemInterface $item)
 {
     $this->items[$item->getId()] = $item;
 }
Beispiel #3
0
 public function addItem(ItemInterface $item)
 {
     $this->init();
     $writer = $this->xmlWriter;
     $writer->startElement('DEAL');
     $this->map('ID', $item->getId());
     $_cities = $item->getCities();
     if ($_cities) {
         $writer->startElement('CITIES');
         foreach ($_cities as $_iterItem) {
             $this->map('CITY', $_iterItem);
         }
         $writer->endElement();
     }
     $this->map('TITLE_SHORT', $item->getTitleShort());
     $this->map('TITLE', $item->getTitle());
     $this->map('URL', $item->getUrl());
     $_images = $item->getImages();
     if ($_images) {
         $writer->startElement('IMAGES');
         foreach ($_images as $_iterItem) {
             $this->map('IMAGE', $_iterItem);
         }
         $writer->endElement();
     }
     $this->map('FINAL_PRICE', $item->getFinalPrice());
     $this->map('ORIGINAL_PRICE', $item->getOriginalPrice());
     $this->map('LANGUAGE', $item->getLanguage());
     $this->map('CURRENCY', $item->getCurrency());
     $this->map('CUSTOMERS', $item->getCustomers());
     $this->map('MIN_CUSTOMERS', $item->getMinCustomers());
     $this->map('MAX_CUSTOMERS', $item->getMaxCustomers());
     $this->map('DEAL_START', $item->getDealStart());
     $this->map('DEAL_END', $item->getDealEnd());
     $this->map('VOUCHER_START', $item->getVoucherStart());
     $this->map('VOUCHER_END', $item->getVoucherEnd());
     $this->map('CATEGORY', $item->getCategory());
     $_tags = $item->getTags();
     if ($_tags) {
         $writer->startElement('TAGS');
         foreach ($item->getTags() as $_iterItem) {
             $this->map('TAG', $_iterItem);
         }
         $writer->endElement();
     }
     $writer->startElement('PROVIDER');
     $this->map('PROVIDER_TITLE', $item->getProviderTitle());
     $this->map('PROVIDER_ADDRESS', $item->getProviderAddress());
     $this->map('PROVIDER_GPS_LAT', $item->getProviderGPSLat());
     $this->map('PROVIDER_GPS_LNG', $item->getProviderGPSLng());
     $this->map('PROVIDER_WEB', $item->getProviderWeb());
     foreach ($item->getProviderEmail() as $_iterItem) {
         $this->map('PROVIDER_EMAIL', $_iterItem);
     }
     foreach ($item->getProviderPhone() as $_iterItem) {
         $this->map('PROVIDER_PHONE', $_iterItem);
     }
     $writer->endElement();
     $this->map('ADULT', $item->getAdult());
     $_variants = $item->getVariants();
     if ($_variants) {
         $writer->startElement('VARIANTS');
         foreach ($_variants as $_iterItem) {
             $writer->startElement('VARIANT');
             $this->map('ID', $_iterItem->getId());
             $this->map('TITLE', $_iterItem->getTitle());
             $this->map('URL', $_iterItem->getUrl());
             $this->map('FINAL_PRICE', $_iterItem->getFinalPrice());
             $this->map('ORIGINAL_PRICE', $_iterItem->getOriginalPrice());
             $this->map('MAX_CUSTOMERS', $_iterItem->getMaxCustomers());
             $writer->endElement();
         }
         $writer->endElement();
     }
     $writer->endElement();
     $writer->flush();
 }
 /**
  * Removes a relationship from the collection.
  *
  * @param string $name The relationship name.
  */
 public function remove($name, ItemInterface $item)
 {
     unset($this->relationships[$name][$item->getId()]);
     if (count($this->relationships[$name]) === 0) {
         unset($this->relationships[$name]);
     }
 }