|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of dispositif/wikibot application (@github) |
|
4
|
|
|
* 2019-2023 © Philippe M./Irønie <[email protected]> |
|
5
|
|
|
* For the full copyright and MIT license information, view the license file. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
declare(strict_types=1); |
|
9
|
|
|
|
|
10
|
|
|
namespace App\Domain\WikiOptimizer; |
|
11
|
|
|
|
|
12
|
|
|
use App\Domain\Models\Wiki\ArticleTemplate; |
|
13
|
|
|
use App\Domain\Models\Wiki\LienWebTemplate; |
|
14
|
|
|
use App\Domain\Models\Wiki\OuvrageTemplate; |
|
15
|
|
|
use App\Domain\Models\Wiki\WikiTemplateInterface; |
|
16
|
|
|
use App\Infrastructure\FileManager; |
|
17
|
|
|
use Psr\Log\LoggerInterface; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* TODO static factory create dependency ! (use DI). |
|
21
|
|
|
* Class OptimizerFactory |
|
22
|
|
|
*/ |
|
23
|
|
|
class OptimizerFactory |
|
24
|
|
|
{ |
|
25
|
|
|
public static function fromTemplate( |
|
26
|
|
|
WikiTemplateInterface $template, |
|
27
|
|
|
?string $wikiPageTitle = null, |
|
28
|
|
|
?LoggerInterface $log = null |
|
29
|
|
|
): ?TemplateOptimizerInterface { |
|
30
|
|
|
if ($template instanceof OuvrageTemplate) { |
|
31
|
|
|
return new OuvrageOptimize($template, $wikiPageTitle, $log, new FileManager()); |
|
32
|
|
|
// todo dependency inversion. FileManager used for ProcessLocation() only. |
|
33
|
|
|
} |
|
34
|
|
|
if ($template instanceof ArticleTemplate) { |
|
35
|
|
|
return new ArticleOptimizer($template, $wikiPageTitle, $log); |
|
36
|
|
|
} |
|
37
|
|
|
if ($template instanceof LienWebTemplate) { |
|
38
|
|
|
return new LienWebOptimizer($template, $wikiPageTitle, $log); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
return null; |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|