Skip to content

Commit a6214a3

Browse files
committed
+ read and list functions
1 parent 2460d3e commit a6214a3

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Diff for: src/models/Storage.php

+30
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,34 @@ public static function mkdir($dir)
174174
}
175175
}
176176

177+
public function readJson($path)
178+
{
179+
return Json::decode(file_get_contents($this->buildPath($path)));
180+
}
181+
182+
protected function readPackagesJson()
183+
{
184+
$data = $this->readJson('packages.json');
185+
186+
return $data['provider-includes'];
187+
}
188+
189+
protected function readProvider($path)
190+
{
191+
$data = $this->readJson($path);
192+
193+
return $data['providers'];
194+
}
195+
196+
public function listPackages()
197+
{
198+
$packages = [];
199+
$providers = $this->readPackagesJson();
200+
foreach ($providers as $path => $data) {
201+
$path = strtr($path, ['%hash%' => $data['sha256']]);
202+
$packages = array_merge($packages, $this->readProvider($path));
203+
}
204+
205+
return $packages;
206+
}
177207
}

0 commit comments

Comments
 (0)