1 | <?php |
||
31 | class Fetcher { |
||
32 | |||
33 | const DEFAULT_BASE_URL = 'https://updates.owncloud.com/server/'; |
||
34 | |||
35 | /** |
||
36 | * @var Locator $locator |
||
37 | */ |
||
38 | protected $locator; |
||
39 | |||
40 | /** |
||
41 | * @var ConfigReader $configReader |
||
42 | */ |
||
43 | protected $configReader; |
||
44 | |||
45 | /** |
||
46 | * @var Client $httpClient |
||
47 | */ |
||
48 | protected $httpClient; |
||
49 | protected $requiredFeedEntries = [ |
||
50 | 'version', |
||
51 | 'versionstring', |
||
52 | 'url' |
||
53 | ]; |
||
54 | |||
55 | /** |
||
56 | * Constructor |
||
57 | * |
||
58 | * @param Client $httpClient |
||
59 | * @param Locator $locator |
||
60 | * @param ConfigReader $configReader |
||
61 | */ |
||
62 | 3 | public function __construct(Client $httpClient, Locator $locator, ConfigReader $configReader){ |
|
67 | |||
68 | /** |
||
69 | * Download new ownCloud package |
||
70 | * @param Feed $feed |
||
71 | * @param Callable $onProgress |
||
72 | * @throws \Exception |
||
73 | * @throws \UnexpectedValueException |
||
74 | */ |
||
75 | public function getOwncloud(Feed $feed, callable $onProgress){ |
||
95 | |||
96 | /** |
||
97 | * Produce a local path to save the package to |
||
98 | * @param Feed $feed |
||
99 | * @return string |
||
100 | */ |
||
101 | public function getBaseDownloadPath(Feed $feed){ |
||
105 | |||
106 | /** |
||
107 | * Get md5 sum for the package |
||
108 | * @param Feed $feed |
||
109 | * @return string |
||
110 | */ |
||
111 | public function getMd5(Feed $feed){ |
||
117 | |||
118 | /** |
||
119 | * Read update feed for new releases |
||
120 | * @return Feed |
||
121 | */ |
||
122 | 3 | public function getFeed(){ |
|
140 | |||
141 | /** |
||
142 | * @return mixed|string |
||
143 | */ |
||
144 | 3 | public function getUpdateChannel(){ |
|
152 | |||
153 | /** |
||
154 | * Produce complete feed URL |
||
155 | * @return string |
||
156 | */ |
||
157 | 3 | protected function getFeedUrl(){ |
|
175 | |||
176 | /** |
||
177 | * Get URL content |
||
178 | * @param string $url |
||
179 | * @return string |
||
180 | * @throws \UnexpectedValueException |
||
181 | */ |
||
182 | 3 | protected function download($url){ |
|
187 | |||
188 | /** |
||
189 | * Check if request was successful |
||
190 | * @param \GuzzleHttp\Message\ResponseInterface $response |
||
191 | * @throws \UnexpectedValueException |
||
192 | */ |
||
193 | 3 | protected function validateResponse($response){ |
|
203 | |||
204 | } |
||
205 |