/** * {@inheritdoc} */ public function map(ParameterBag $item) { $bag = new FeedItemBag($this->origin, $this->feed, call_user_func($this->originalIdCallback, $item), $item->all()); $bag->setOriginalUrl(call_user_func($this->originalUrlCallback, $item)); $bag->setDatetimeModified(call_user_func($this->modificationDateCallback, $item)); return $bag; }
/** * @dataProvider getModifiedItems */ public function testModifiedItems(\DateTime $sourceDate, \DateTime $itemDate = null) { $this->source->setDatetimeModified($sourceDate); $item = new FeedItemBag(new OriginMock(1234), new FeedMock(123), '123abc'); $item->setDatetimeModified($itemDate); $filter = new ModifiedItemFilter($this->sourceManager); $filter->filter($item); }
/** * {@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 getOriginalUrl(FeedItemBag $item) { return $item->getOriginalUrl(); }