1
|
|
|
<?php |
2
|
|
|
namespace View\Workers\FileWorker; |
3
|
|
|
|
4
|
|
|
use View\Contexts\Context; |
5
|
|
|
use View\Contexts\HtmlContext; |
6
|
|
|
use View\Helpers\RecursiveStringPath; |
7
|
|
|
use View\Proxying\ObjectProxyFactory; |
8
|
|
|
use View\Workers\WorkerConfiguration; |
9
|
|
|
|
10
|
|
|
class FileWorkerConfiguration implements WorkerConfiguration { |
11
|
|
|
/** @var Context */ |
12
|
|
|
private $context; |
13
|
|
|
/** @var RecursiveStringPath */ |
14
|
|
|
private $recursiveAccessor; |
15
|
|
|
/** @var ObjectProxyFactory */ |
16
|
|
|
private $objectProxyFactory; |
17
|
|
|
/** @var array */ |
18
|
|
|
private $config; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @param Context $context |
22
|
|
|
* @param RecursiveStringPath $recursiveAccessor |
23
|
|
|
* @param ObjectProxyFactory $objectProxyFactory |
24
|
|
|
* @param array $config |
25
|
|
|
*/ |
26
|
|
|
public function __construct(Context $context = null, RecursiveStringPath $recursiveAccessor = null, ObjectProxyFactory $objectProxyFactory = null, array $config = []) { |
27
|
|
|
if($context === null) { |
28
|
|
|
$context = new HtmlContext(); |
29
|
|
|
} |
30
|
|
|
if($recursiveAccessor === null) { |
31
|
|
|
$recursiveAccessor = new RecursiveStringPath(); |
32
|
|
|
} |
33
|
|
|
if($objectProxyFactory === null) { |
34
|
|
|
$objectProxyFactory = new ObjectProxyFactory($context); |
35
|
|
|
} |
36
|
|
|
$this->context = $context; |
37
|
|
|
$this->recursiveAccessor = $recursiveAccessor; |
38
|
|
|
$this->objectProxyFactory = $objectProxyFactory; |
39
|
|
|
$this->config = $config; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return Context |
44
|
|
|
*/ |
45
|
|
|
public function getContext() { |
46
|
|
|
return $this->context; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return RecursiveStringPath |
51
|
|
|
*/ |
52
|
|
|
public function getRecursiveAccessor() { |
53
|
|
|
return $this->recursiveAccessor; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return ObjectProxyFactory |
58
|
|
|
*/ |
59
|
|
|
public function getObjectProxyFactory() { |
60
|
|
|
return $this->objectProxyFactory; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return array |
65
|
|
|
*/ |
66
|
|
|
public function getPaths() { |
67
|
|
|
if(array_key_exists('paths', $this->config)) { |
68
|
|
|
return $this->config['paths']; |
69
|
|
|
} |
70
|
|
|
return []; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|