/** * Adds the item and its price to the array. * @param \App\Model\ItemMenu $itemMenu */ public function addItem(ItemMenu $menuItem) { $id = $menuItem->getId(); //If the object doesn't have an id, return if (is_null($id)) { return; } //If the ItemMenu is already in the array, return foreach ($this->_menuItems as $idMenuItem) { if ($id->__toString() == $idMenuItem->__toString()) { return; } } $this->_menuItems[] = $id; }
/** * Set an ItemMenu with its associated quantity * @param \App\Model\ItemMenu $itemMenu * @param int $quantity */ public function setItem(ItemMenu $itemMenu, $quantity) { $this->_menuItems[$itemMenu->getId()->__toString()] = $quantity; }