Пример #1
0
 /**
  * @param Entity\TblCommodity $tblCommodity
  * @param TblItem             $tblItem
  * @param                     $Quantity
  *
  * @return bool
  */
 public function actionAddCommodityItem(TblCommodity $tblCommodity, TblItem $tblItem, $Quantity)
 {
     $Manager = $this->Connection->getEntityManager();
     $Entity = $Manager->getEntity('TblCommodityItem')->findOneBy(array(TblCommodityItem::ATTR_TBL_COMMODITY => $tblCommodity->getId(), TblCommodityItem::ATTR_TBL_ITEM => $tblItem->getId()));
     if (null === $Entity) {
         $Entity = new TblCommodityItem();
         $Entity->setTblCommodity($tblCommodity);
         $Entity->setTblItem($tblItem);
         $Entity->setQuantity(str_replace(',', '.', $Quantity));
         $Manager->saveEntity($Entity);
         Protocol::useService()->createInsertEntry($this->Connection->getDatabase(), $Entity);
     }
     return $Entity;
 }