Przebudowa - code review aplikaacji, podział na moduły.
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user