/** * @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. }
public function validate(ParameterBag $item) { /* @var FeedItemBag $item */ $originalId = $item->getOriginalId(); // non-scalar values if (!is_scalar($originalId)) { throw new ValidationException(sprintf('Non-scalar value for original_id encountered: "%s"', var_export($originalId, true))); } $originalId = (string) $originalId; // non-positive numerical values if (is_numeric($originalId) && intval($originalId) < 1) { throw new ValidationException(sprintf('Non-positive value for original_id: "%s"', $originalId)); } // empty values or values containing whitespace if (empty(trim($originalId))) { throw new ValidationException(sprintf('Invalid original_id: "%s"', $originalId)); } }