1
0
mirror of https://github.com/Ne-Lexa/php-zip.git synced 2025-08-13 02:37:19 +02:00

Fixed problem with cloning a zip container.

This commit is contained in:
Ne-Lexa
2020-01-22 12:48:15 +03:00
parent 5ec656fde4
commit 943cf3e777
10 changed files with 285 additions and 47 deletions

View File

@@ -0,0 +1,28 @@
<?php
namespace PhpZip\Tests\Internal\CustomZip;
use PhpZip\Model\Extra\Fields\NewUnixExtraField;
use PhpZip\Model\Extra\Fields\NtfsExtraField;
use PhpZip\ZipFile;
/**
* Class ZipFileWithBeforeSave.
*/
class ZipFileWithBeforeSave extends ZipFile
{
/**
* Event before save or output.
*/
protected function onBeforeSave()
{
$now = new \DateTimeImmutable();
$ntfsTimeExtra = NtfsExtraField::create($now, $now->modify('-1 day'), $now->modify('-10 day'));
$unixExtra = new NewUnixExtraField();
foreach ($this->zipContainer->getEntries() as $entry) {
$entry->addExtraField($ntfsTimeExtra);
$entry->addExtraField($unixExtra);
}
}
}