🏗️ Allow access to Config from Collectors

This commit is contained in:
Shikiryu committed 2021-02-22 17:43:40 +01:00
1 parent c8bbc35886
commit 48cc6e9f28
3 files changed
+32 -7

No files matched your search

+2 -2
View File
@@ -22,13 +22,13 @@ class YahooImageCollector extends Collector
*/
public function getRandomImage()
{
$word_to_search = $this->generateRandomWord();
$word_to_search = $this->getConfig()->get('collector.keywords.keywords', $this->generateRandomWord());
$client = new Client();
$crawler = $client->request('GET', sprintf(self::SEARCH_URL, $word_to_search));
$imgs = $crawler->filter('noscript img');
if ($imgs->count() < 20) {
return $this->getRandomImage();
return $this->getRandomImage(); // FIXME possible infinite loop if keywords is given
}
$img_url = $imgs->eq(random_int(0, $imgs->count() - 1))->attr('src');