Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function handle(Feed $feed, FeedItemBag $item)
 {
     // get source and set the data to it
     $source = $this->sourceManager->findSourceOrCreate($feed, $item->getOriginalId(), $item->getOriginalUrl());
     // update original url, because it might have changed since the last time
     // we imported the feed
     $source->setOriginalUrl($item->getOriginalUrl());
     // save data
     $source->setData($item->all());
     try {
         $this->validate($source);
         $this->sourceManager->persist($source);
         return $source;
     } catch (\Exception $exception) {
         $this->sourceManager->detach($source);
         throw new FailedItemException($source, $exception->getMessage(), $exception->getCode(), $exception);
     }
 }
 /**
  * @param FeedItemBag $item
  *
  * @return string
  */
 protected function getOriginalId(FeedItemBag $item)
 {
     return $item->getOriginalId();
 }