/** * @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); } }
/** * @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); } }