CustomZipWriter.php 927 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of the nelexa/zip package.
  5. * (c) Ne-Lexa <https://github.com/Ne-Lexa/php-zip>
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. namespace PhpZip\Tests\Internal\CustomZip;
  10. use PhpZip\IO\ZipWriter;
  11. use PhpZip\Model\Extra\Fields\NewUnixExtraField;
  12. use PhpZip\Model\Extra\Fields\NtfsExtraField;
  13. class CustomZipWriter extends ZipWriter
  14. {
  15. protected function beforeWrite(): void
  16. {
  17. parent::beforeWrite();
  18. $now = new \DateTimeImmutable();
  19. $ntfsTimeExtra = NtfsExtraField::create($now, $now->modify('-1 day'), $now->modify('-10 day'));
  20. $unixExtra = new NewUnixExtraField();
  21. foreach ($this->zipContainer->getEntries() as $entry) {
  22. $entry->addExtraField($ntfsTimeExtra);
  23. $entry->addExtraField($unixExtra);
  24. }
  25. }
  26. }