/** * @inheritdoc */ public function filter(ParameterBag $item) { /** @var FeedItemBag $item */ $item->getOriginalId(); // check if source already exists and is blocked if (null === ($source = $this->sourceManager->findSource($item->getFeed(), $item->getOriginalId()))) { return; } if ($source->isBlocked() === true) { throw new FilterException('Source is blocked'); } }
/** * {@inheritdoc} */ public function filter(ParameterBag $item) { /** @var FeedItemBag $item */ // if source does not exist yet, by all means process it if (null === ($source = $this->sourceManager->findSource($item->getFeed(), $item->getOriginalId()))) { return; } // first try modification date if (null !== ($mutationDate = $item->getDatetimeModified())) { if ($source->getDatetimeModified() > $mutationDate) { throw new FilterException('Item is not modified'); } } // item is modified or we don't have enough information to determine that, either way continue. }
/** * {@inheritdoc} */ public function clear() { $this->sourceManager->clear(); }
public function setUp() { $this->source = new SourceMock(123); $this->sourceManager = $this->getMockBuilder('FM\\IoBundle\\Source\\Manager\\ImportSourceManager')->disableOriginalConstructor()->setMethods(['findSource'])->getMock(); $this->sourceManager->expects($this->any())->method('findSource')->will($this->returnValue($this->source)); }