예제 #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()));
     }
 }
예제 #2
0
 /**
  * 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]);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function setParent(ItemInterface $parent = null)
 {
     if ($parent === $this) {
         throw new \InvalidArgumentException('An item cannot have itself as a parent.');
     }
     if ($parent === $this->parent) {
         return $this;
     }
     if ($this->parent) {
         $this->parent->remove($this);
     }
     $this->parent = $parent;
     if ($parent && !$parent->has($this)) {
         $this->parent->add($this);
     }
     return $this;
 }
예제 #4
0
 /**
  * @param ItemInterface $item
  */
 public function addItem(ItemInterface $item)
 {
     $this->items[$item->getId()] = $item;
 }
예제 #5
0
 /**
  * Moves child to specified position. Rearange other children accordingly.
  *
  * @param \Knp\Menu\ItemInterface $child Child to move.
  * @param integer $position Position to move child to.
  * @return \Knp\Menu\ItemInterface
  */
 public function moveChildToPosition(ItemInterface $child, $position)
 {
     $name = $child->getName();
     $order = array_keys($this->children);
     $oldPosition = array_search($name, $order);
     unset($order[$oldPosition]);
     $order = array_values($order);
     array_splice($order, $position, 0, $name);
     $this->reorderChildren($order);
     return $this;
 }
예제 #6
0
 /**
  * @return string
  */
 public function getUrl()
 {
     return $this->item->getUrl();
 }
예제 #7
0
 /**
  * @param ItemInterface $item
  *
  * @return WishlistInterface
  */
 public function addItem(ItemInterface $item) : WishlistInterface
 {
     $item->setWishlist($this);
     $this->items->add($item);
     return $this;
 }
예제 #8
0
 /**
  * Configures the newly created item with the passed options
  *
  * @param ItemInterface $item
  * @param array         $options
  */
 protected function configureItem(ItemInterface $item, array $options)
 {
     $item->setName($options['name'])->setDescription($options['description'])->setLatitude($options['latitude'])->setLongitude($options['longitude'])->setAttributes($options['attributes']);
 }
예제 #9
0
 public function getLevel()
 {
     return $this->parent ? $this->parent->getLevel() + 1 : 0;
 }
예제 #10
0
파일: Itemable.php 프로젝트: vespolina/core
 /**
  * @inheritdoc
  */
 public function addItem(ItemInterface $item)
 {
     $item->setParent($this);
     $this->items[] = $item;
 }
예제 #11
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();
 }
예제 #12
0
 /**
  * @param ItemInterface $item
  */
 public function addItem(ItemInterface $item)
 {
     $route = $item->getRoute();
     $this->items[$route] = $item;
 }