1 |
cd5c298a
|
Geoffroy Desvernay
|
<?php
|
2 |
|
|
namespace TYPO3\PharStreamWrapper;
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
fbb66ca6
|
Assos Assos
|
use TYPO3\PharStreamWrapper\Resolver\PharInvocation;
|
15 |
|
|
use TYPO3\PharStreamWrapper\Resolver\PharInvocationCollection;
|
16 |
|
|
use TYPO3\PharStreamWrapper\Resolver\PharInvocationResolver;
|
17 |
|
|
|
18 |
|
|
class Manager
|
19 |
cd5c298a
|
Geoffroy Desvernay
|
{
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
private static $instance;
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
private $behavior;
|
29 |
|
|
|
30 |
fbb66ca6
|
Assos Assos
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
private $resolver;
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
private $collection;
|
39 |
|
|
|
40 |
cd5c298a
|
Geoffroy Desvernay
|
|
41 |
|
|
|
42 |
fbb66ca6
|
Assos Assos
|
|
43 |
|
|
|
44 |
cd5c298a
|
Geoffroy Desvernay
|
|
45 |
|
|
|
46 |
fbb66ca6
|
Assos Assos
|
public static function initialize(
|
47 |
|
|
Behavior $behaviour,
|
48 |
|
|
Resolvable $resolver = null,
|
49 |
|
|
Collectable $collection = null
|
50 |
|
|
) {
|
51 |
cd5c298a
|
Geoffroy Desvernay
|
if (self::$instance === null) {
|
52 |
fbb66ca6
|
Assos Assos
|
self::$instance = new self($behaviour, $resolver, $collection);
|
53 |
cd5c298a
|
Geoffroy Desvernay
|
return self::$instance;
|
54 |
|
|
}
|
55 |
|
|
throw new \LogicException(
|
56 |
|
|
'Manager can only be initialized once',
|
57 |
|
|
1535189871
|
58 |
|
|
);
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
public static function instance()
|
65 |
|
|
{
|
66 |
|
|
if (self::$instance !== null) {
|
67 |
|
|
return self::$instance;
|
68 |
|
|
}
|
69 |
|
|
throw new \LogicException(
|
70 |
|
|
'Manager needs to be initialized first',
|
71 |
|
|
1535189872
|
72 |
|
|
);
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
public static function destroy()
|
79 |
|
|
{
|
80 |
|
|
if (self::$instance === null) {
|
81 |
|
|
return false;
|
82 |
|
|
}
|
83 |
|
|
self::$instance = null;
|
84 |
|
|
return true;
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
fbb66ca6
|
Assos Assos
|
|
90 |
|
|
|
91 |
cd5c298a
|
Geoffroy Desvernay
|
|
92 |
fbb66ca6
|
Assos Assos
|
private function __construct(
|
93 |
|
|
Behavior $behaviour,
|
94 |
|
|
Resolvable $resolver = null,
|
95 |
|
|
Collectable $collection = null
|
96 |
|
|
) {
|
97 |
|
|
if ($collection === null) {
|
98 |
|
|
$collection = new PharInvocationCollection();
|
99 |
|
|
}
|
100 |
|
|
if ($resolver === null) {
|
101 |
|
|
$resolver = new PharInvocationResolver();
|
102 |
|
|
}
|
103 |
|
|
$this->collection = $collection;
|
104 |
|
|
$this->resolver = $resolver;
|
105 |
cd5c298a
|
Geoffroy Desvernay
|
$this->behavior = $behaviour;
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
public function assert($path, $command)
|
114 |
|
|
{
|
115 |
|
|
return $this->behavior->assert($path, $command);
|
116 |
|
|
}
|
117 |
fbb66ca6
|
Assos Assos
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
public function resolve($path, $flags = null)
|
124 |
|
|
{
|
125 |
|
|
return $this->resolver->resolve($path, $flags);
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
|
131 |
|
|
public function getCollection()
|
132 |
|
|
{
|
133 |
|
|
return $this->collection;
|
134 |
|
|
}
|
135 |
cd5c298a
|
Geoffroy Desvernay
|
} |