Skip to content

Commit

Permalink
feat: added progress callback for installation (#2492)
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Oct 15, 2023
1 parent c8c31b7 commit eb4f524
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions phpmyfaq/src/phpMyFAQ/Setup/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ public function installPackage(callable $progressCallback): bool
RecursiveIteratorIterator::SELF_FIRST
);

$totalFiles = iterator_count($sourceDirIterator);
$currentFile = 0;

foreach ($sourceDirIterator as $item) {
$source = $item->getPathName();
$destination = $destinationDir . DIRECTORY_SEPARATOR . $sourceDirIterator->getSubPathName();
Expand All @@ -304,6 +307,10 @@ public function installPackage(callable $progressCallback): bool
} else {
copy($source, $destination);
}

$currentFile++;
$progress = $totalFiles > 0 ? sprintf('%d%%', ($currentFile / $totalFiles) * 100) : 100;
call_user_func($progressCallback, $progress);
}
return true;
}
Expand Down

0 comments on commit eb4f524

Please sign in to comment.