[WIP] Setup of skeleton
This commit is contained in:
48
app/Repositories/Core/Cache.php
Normal file
48
app/Repositories/Core/Cache.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use TheSeer\DirectoryScanner\DirectoryScanner;
|
||||
|
||||
class Cache
|
||||
{
|
||||
public static function getAutoVersion($file)
|
||||
{
|
||||
$filePath = public_path() . $file;
|
||||
|
||||
if (!file_exists($filePath)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$version = filemtime($filePath);
|
||||
|
||||
return '?v=' . $version;
|
||||
}
|
||||
|
||||
public static function getFilesVersion($folder, $type)
|
||||
{
|
||||
$folder = str_replace('.', '/', $folder);
|
||||
// dump($folder);
|
||||
// dump($type);
|
||||
// exit;
|
||||
$scanner = new DirectoryScanner;
|
||||
$scanner->addInclude('*.'.$type);
|
||||
// $scanner->addExclude('*filter*');
|
||||
// $scanner->addExclude('./src/*');
|
||||
$path = public_path() . '/' . $folder;
|
||||
|
||||
$data = [];
|
||||
foreach ($scanner($path) as $i) {
|
||||
// dump($i);
|
||||
$sub = $i->getPath();
|
||||
$sub = str_replace($path, '', $sub);
|
||||
$sub = str_replace('\\', '/', $sub);
|
||||
// dump($sub);
|
||||
$filename = '/' . $folder . $sub . '/' . $i->getFilename();
|
||||
// dump($filename);
|
||||
$mtime = $i->getMTime();
|
||||
$data[$filename] = $mtime;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user