Przebudowa - code review aplikaacji, podział na moduły.

This commit is contained in:
2026-09-25 15:33:32 +02:00
parent 45354071bd
commit 9d25de0d89
17 changed files with 2646 additions and 2148 deletions
+22
View File
@@ -17,6 +17,28 @@ function publicAssetVersion(string $publicDir, string $relativePath): string
return $mtime !== false ? (string) $mtime : '0';
}
/**
* Najnowszy mtime wśród pliku głównego i wszystkich .js w katalogu modules/.
*/
function publicJsBundleVersion(string $publicDir, string $entryRelativePath, string $modulesRelativeDir = 'assets/js/modules'): string
{
$versions = [(int) publicAssetVersion($publicDir, $entryRelativePath)];
$modulesDir = $publicDir . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, ltrim($modulesRelativeDir, '/'));
if (is_dir($modulesDir)) {
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($modulesDir, FilesystemIterator::SKIP_DOTS)
);
foreach ($iterator as $file) {
if ($file->isFile() && strtolower($file->getExtension()) === 'js') {
$versions[] = (int) $file->getMTime();
}
}
}
return (string) max($versions);
}
function assetVersionAttr(string $version): string
{
return htmlspecialchars($version, ENT_QUOTES, 'UTF-8');