/** * Adds source to the internal cache. * * @param SourceInterface $source */ protected function cache(SourceInterface $source = null) { if (null === $source) { return; } // mark as visited $source->setDatetimeLastVisited(new \DateTime()); // cache by id if ($source->getId()) { $this->sources[$source->getId()] = $source; } $hash = null; if (null !== ($feed = $source->getFeed())) { $hash = $this->getFeedHash($feed); } elseif (null !== ($scraper = $source->getScraper())) { $hash = $this->getScraperHash($scraper); } // must have hash and original id if (!$hash || !$source->getOriginalId()) { return; } $this->originSources[$hash][$source->getOriginalId()] = $source; }