コード例 #1
0
 /**
  * Revisits a source. This basically means doing a scrape operation on the
  * source origin, only this time the source will be removed if the original
  * url was not found.
  *
  * @param SourceInterface $source       The source to revisit.
  * @param bool            $async        If true, makes the scrape action asynchronous.
  *                                      The revisit action will happen right away, but any
  *                                      consecutive scrape actions will be queued. Use this
  *                                      when calling the revisit action from an asynchronous
  *                                      context.
  * @param bool            $disableLimit Whether to disable the rate limit when revisiting.
  */
 public function revisit(SourceInterface $source, $async = false, $disableLimit = false)
 {
     if (!$source->getOriginalUrl()) {
         throw new \InvalidArgumentException('Source does not contain an original url');
     }
     // check if source is still fresh
     if ($this->isFresh($source)) {
         return;
     }
     $scraper = $this->createScraper($source->getScraper(), $disableLimit);
     $scraper->setAsync($async);
     try {
         $scraper->scrape($source->getScraper(), $source->getOriginalUrl(), false);
     } catch (NotFoundException $e) {
         $this->removeSource($source);
     }
 }