コード例 #1
0
 /**
  * @inheritdoc
  */
 public function handle(ScrapedItemBag $item)
 {
     // get source and set the data to it
     $source = $this->findSourceOrCreate($item);
     $source->setData($item->all());
     $source->setDatetimeLastVisited(new \DateTime());
     try {
         $this->validate($source);
         $this->sourceManager->persist($source);
         $this->sourceManager->flush($source);
         return $source;
     } catch (\Exception $exception) {
         $this->sourceManager->detach($source);
         throw new FailedItemException($source, $exception->getMessage(), $exception->getCode(), $exception);
     }
 }
コード例 #2
0
 /**
  * @inheritdoc
  */
 public function handle(FeedItemBag $item)
 {
     // get source and set the data to it
     $source = $this->sourceManager->findSourceByFeedOrCreate($item->getFeed(), $item->getOriginalId(), $item->getOriginalUrl());
     // save data
     $source->setData($item->all());
     $source->setOriginalUrl($item->getOriginalUrl());
     try {
         $this->validate($source);
         $this->sourceManager->persist($source);
         $this->sourceManager->flush($source);
         return $source;
     } catch (\Exception $exception) {
         $this->sourceManager->detach($source);
         throw new FailedItemException($source, $exception->getMessage(), $exception->getCode(), $exception);
     }
 }