- ContentSource handling in message - ContentSource list, add/update ui - nextPageSelector and imageSelector can be null - cleanup
29 lines
744 B
PHP
29 lines
744 B
PHP
<?php
|
|
|
|
namespace App\Twig\Extension;
|
|
|
|
use Twig\Extension\AbstractExtension;
|
|
use Twig\TwigFunction;
|
|
|
|
class AppExtension extends AbstractExtension
|
|
{
|
|
public function getFunctions(): array
|
|
{
|
|
return [
|
|
new TwigFunction('get_placeholder', [$this, 'getPlaceholder']),
|
|
];
|
|
}
|
|
|
|
public function getPlaceholder(string $fieldName): string
|
|
{
|
|
return match ($fieldName) {
|
|
'baseUrl' => 'https://example.com',
|
|
'imageSelector' => '.manga-image img',
|
|
'chapterUrlFormat' => 'https://example.com/manga/{slug}/chapter-{number}',
|
|
'nextPageSelector' => '.next-page',
|
|
'scrapingType' => 'Select scraping type',
|
|
default => '',
|
|
};
|
|
}
|
|
}
|