- Refactor MangaScraperService (not used everywhere now)
- Added JavascriptScraper.php
- Added alternatives slugs in Manga.php
- Improvement in manga edit form
This commit is contained in:
Jérémy Guillot
2024-07-21 19:08:46 +02:00
parent ff59aa5d77
commit fafff5014c
21 changed files with 1180 additions and 28 deletions

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Service\Scraper;
use App\Entity\ContentSource;
class ScraperFactory
{
private array $scrapers;
public function __construct(iterable $scrapers)
{
$this->scrapers = iterator_to_array($scrapers);
}
public function createScraper(ContentSource $contentSource): ScraperInterface
{
foreach ($this->scrapers as $scraper) {
if ($scraper->supports($contentSource->getScrapingType())) {
return $scraper;
}
}
throw new \InvalidArgumentException('Unsupported scraping type: ' . $contentSource->getScrapingType());
}
}