1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Oliverde8\PhpEtlBundle\Services; |
4
|
|
|
|
5
|
|
|
use Oliverde8\Component\PhpEtl\ExecutionContextFactoryInterface; |
6
|
|
|
use Oliverde8\PhpEtlBundle\Model\ExecutionContext; |
7
|
|
|
use Oliverde8\PhpEtlBundle\Model\LoggerProxy; |
8
|
|
|
|
9
|
|
|
class ExecutionContextFactory implements ExecutionContextFactoryInterface |
10
|
|
|
{ |
11
|
|
|
private ChainWorkDirManager $chainWorkDirManager; |
12
|
|
|
|
13
|
|
|
private LoggerFactory $loggerFactory; |
14
|
|
|
|
15
|
|
|
private FileSystemFactory $fileSystemFactory; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @param ChainWorkDirManager $chainWorkDirManager |
19
|
|
|
* @param LoggerFactory $loggerFactory |
20
|
|
|
* @param FileSystemFactory $fileSystemFactory |
21
|
|
|
*/ |
22
|
|
|
public function __construct( |
23
|
|
|
ChainWorkDirManager $chainWorkDirManager, |
24
|
|
|
LoggerFactory $loggerFactory, |
25
|
|
|
FileSystemFactory $fileSystemFactory |
26
|
|
|
) { |
27
|
|
|
$this->chainWorkDirManager = $chainWorkDirManager; |
28
|
|
|
$this->loggerFactory = $loggerFactory; |
29
|
|
|
$this->fileSystemFactory = $fileSystemFactory; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
public function get(array $parameters): ExecutionContext |
34
|
|
|
{ |
35
|
|
|
$logger = new LoggerProxy($this->loggerFactory->get($parameters['etl']['execution'])); |
36
|
|
|
$fileSystem = $this->fileSystemFactory->get($parameters['etl']['execution']); |
37
|
|
|
$workDir = $this->chainWorkDirManager->getLocalTmpWorkDir($parameters['etl']['execution']); |
38
|
|
|
|
39
|
|
|
$context = new ExecutionContext($parameters, $fileSystem, $logger, $workDir); |
40
|
|
|
$logger->setExecutionContext($context); |
41
|
|
|
|
42
|
|
|
return $context; |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|