Example #1
0
 /**
  * Find settings by given id
  *
  * @param string $id
  * @return Newscoop\News\Settings
  */
 public function find($id)
 {
     $settings = $this->repository->find($id);
     if ($settings === null) {
         $settings = new Settings();
     }
     return $settings;
 }
Example #2
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();
 }