]> BookStack Code Mirror - bookstack/blob - app/Exports/ZipExports/ZipFileReferenceRule.php
4f942e0e78967c4443a545a5c0658029f4ec6afa
[bookstack] / app / Exports / ZipExports / ZipFileReferenceRule.php
1 <?php
2
3 namespace BookStack\Exports\ZipExports;
4
5 use Closure;
6 use Illuminate\Contracts\Validation\ValidationRule;
7 use ZipArchive;
8
9 class ZipFileReferenceRule implements ValidationRule
10 {
11     public function __construct(
12         protected ZipValidationHelper $context,
13     ) {
14     }
15
16
17     /**
18      * @inheritDoc
19      */
20     public function validate(string $attribute, mixed $value, Closure $fail): void
21     {
22         if (!$this->context->zipFileExists($value)) {
23             $fail('validation.zip_file')->translate();
24         }
25     }
26 }