Example #1
0
 /**
  * Save item
  *
  * @param Newscoop\News\Item $item
  * @return void
  */
 public function save(Item $item)
 {
     $persisted = $this->repository->find($item->getId());
     if ($persisted !== null) {
         if ($item->getVersion() < $persisted->getVersion()) {
             return;
         } else {
             // @todo handle append signal
             $this->odm->remove($persisted);
             $this->odm->flush();
         }
     }
     if ($item->isCanceled()) {
         return;
     }
     $this->odm->persist($item);
     $this->odm->flush();
 }