| 1 | <?php |
||
| 9 | class ManifestGenerator |
||
| 10 | { |
||
| 11 | public const FILENAME = 'manifest.json'; |
||
| 12 | |||
| 13 | 1 | public function generate(Passbook $passbook, string $temporaryDirectory): void |
|
| 14 | { |
||
| 15 | 1 | $manifest = [Compiler::PASS_DATA_FILE => $this->hash((string) json_encode($passbook->getData()))]; |
|
| 16 | |||
| 17 | 1 | foreach ($passbook->getImages() as $file) { |
|
| 18 | $manifest[$file->getFilename()] = $this->hash($file->getContents()); |
||
| 19 | } |
||
| 20 | |||
| 21 | 1 | file_put_contents($temporaryDirectory . '/' . self::FILENAME, json_encode($manifest)); |
|
| 22 | 1 | } |
|
| 23 | |||
| 24 | 1 | private function hash(string $data): string |
|
| 28 | } |
||
| 29 |