1 | <?php |
||
33 | class Varnish implements SingletonInterface |
||
34 | { |
||
35 | /** |
||
36 | * @var Http |
||
37 | */ |
||
38 | private $http; |
||
39 | |||
40 | /** |
||
41 | * @var ExtensionConfiguration |
||
42 | */ |
||
43 | private $extensionConfiguration; |
||
44 | |||
45 | /** |
||
46 | * @var LogManager |
||
47 | */ |
||
48 | private $logManager; |
||
49 | |||
50 | /** |
||
51 | * @param Http $http |
||
52 | * @param ExtensionConfiguration $extensionConfiguration |
||
53 | * @param LogManager $logManager |
||
54 | */ |
||
55 | 5 | public function __construct(Http $http, ExtensionConfiguration $extensionConfiguration, LogManager $logManager) |
|
63 | |||
64 | /** |
||
65 | * @return array |
||
66 | */ |
||
67 | 1 | public function shutdown() |
|
68 | { |
||
69 | 1 | $phrases = $this->http->wait(); |
|
70 | 1 | if (is_array($phrases)) { |
|
71 | 1 | foreach ($phrases as $phrase) { |
|
72 | 1 | if ($phrase['success']) { |
|
73 | 1 | $this->logManager->getLogger(__CLASS__)->info($phrase['reason']); |
|
74 | } else { |
||
75 | 1 | $this->logManager->getLogger(__CLASS__)->alert($phrase['reason']); |
|
76 | } |
||
77 | } |
||
78 | } |
||
79 | 1 | return $phrases; |
|
80 | } |
||
81 | |||
82 | /** |
||
83 | * @param TagInterface $tag |
||
84 | * @return Varnish |
||
85 | */ |
||
86 | 2 | public function banByTag(TagInterface $tag) |
|
94 | |||
95 | /** |
||
96 | * @return Varnish |
||
97 | */ |
||
98 | 1 | public function banAll() |
|
103 | |||
104 | /** |
||
105 | * @param string $regex |
||
106 | * @return Varnish |
||
107 | */ |
||
108 | 1 | public function banByRegex($regex) |
|
113 | |||
114 | /** |
||
115 | * @param string $method |
||
116 | * @param array $headers |
||
117 | * @param integer $timeout |
||
118 | */ |
||
119 | 3 | private function request($method, $headers = [], $timeout = null) |
|
129 | } |
||
130 |