|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of forecast.it.fill project. |
|
7
|
|
|
* (c) Patrick Jaja <[email protected]> |
|
8
|
|
|
* This source file is subject to the MIT license that is bundled |
|
9
|
|
|
* with this source code in the file LICENSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace ForecastAutomation\PeriodicalActivity; |
|
13
|
|
|
|
|
14
|
|
|
use ForecastAutomation\Kernel\AbstractFactory; |
|
15
|
|
|
use ForecastAutomation\Log\LogFacade; |
|
16
|
|
|
use ForecastAutomation\PeriodicalActivity\Business\PeriodicalActivityConfigReader; |
|
17
|
|
|
use ForecastAutomation\PeriodicalActivity\Business\PeriodicalActivityDataImportProcess; |
|
18
|
|
|
use ForecastAutomation\QueueClient\QueueClientFacade; |
|
19
|
|
|
use JsonSchema\Validator; |
|
20
|
|
|
|
|
21
|
|
|
class PeriodicalActivityFactory extends AbstractFactory |
|
22
|
|
|
{ |
|
23
|
|
|
public function createPeriodicalActivityDataImportProcess(): PeriodicalActivityDataImportProcess |
|
24
|
|
|
{ |
|
25
|
|
|
return new PeriodicalActivityDataImportProcess( |
|
26
|
|
|
$this->createPeriodicalActivityConfigReader(), |
|
27
|
|
|
$this->getQueueClientFacade() |
|
28
|
|
|
); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function createPeriodicalActivityConfigReader(): PeriodicalActivityConfigReader |
|
32
|
|
|
{ |
|
33
|
|
|
return new PeriodicalActivityConfigReader( |
|
34
|
|
|
$_ENV['PERIODICAL_ACTIVITY_CONFIG'], |
|
35
|
|
|
'file://'.realpath( |
|
36
|
|
|
$this->getSchemaPath() |
|
37
|
|
|
), |
|
38
|
|
|
$this->createValidator(), |
|
39
|
|
|
$this->getLogFacade(), |
|
40
|
|
|
); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function getSchemaPath(): string |
|
44
|
|
|
{ |
|
45
|
|
|
return __DIR__.DIRECTORY_SEPARATOR.'Business/Schema/periodical_activity_config_schema.json'; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function createValidator(): Validator |
|
49
|
|
|
{ |
|
50
|
|
|
return new Validator(); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function getLogFacade(): LogFacade |
|
54
|
|
|
{ |
|
55
|
|
|
return $this->getProvidedDependency(PeriodicalActivityDependencyProvider::LOG_FACADE); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function getQueueClientFacade(): QueueClientFacade |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->getProvidedDependency(PeriodicalActivityDependencyProvider::QUEUE_CLIENT_FACADE); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|