- Cleaned up a bit and added some methods to give Lean/Console more flexibility

This commit is contained in:
mcndave committed 2022-11-29 19:46:40 +00:00
1 parent 531f786747
commit 4bd4cddbff
7 files changed
+78 -26

No files matched your search

+18 -10
View File
@@ -2,8 +2,7 @@
namespace Picea\Caching;
use Picea\Builder,
Picea\Compiler\Context;
use Picea\ { Builder, Compiler\Context };
class Opcache implements Cache {
@@ -57,11 +56,7 @@ class Opcache implements Cache {
if ( file_exists($path = $this->cachePath($viewPath)) ) {
$this->compiled[$viewPath] = include($path);
# if ( $this->compiled[$viewPath]['extends'] ?? false ) {
# $this->compiled($this->compiled[$viewPath]['extends']);
# }
return true;
}
@@ -86,7 +81,7 @@ class Opcache implements Cache {
return true;
}
protected function cachePath(string $fileName = "") : string
public function cachePath(string $fileName = "") : string
{
return implode(DIRECTORY_SEPARATOR, array_filter([ $this->cachePath, $this->cacheFolder, $fileName ? str_replace([ "/", DIRECTORY_SEPARATOR ], "~", Builder::generateClassName($fileName) . ".php") : null ]));
}
@@ -95,7 +90,7 @@ class Opcache implements Cache {
spl_autoload_register(function ($class) use ($namespace) {
$prefix = "$namespace\\";
$baseDir = $this->cachePath() . "/";
$baseDir = $this->cachePath() . DIRECTORY_SEPARATOR;
$len = strlen($prefix);
@@ -103,11 +98,24 @@ class Opcache implements Cache {
return;
}
$file = $baseDir . str_replace('\\', '/', substr($class, $len)) . '.php';
$file = $baseDir . str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $len)) . '.php';
if ( file_exists($file) ) {
require $file;
}
});
}
public function getFilelist() : array
{
return glob($this->cachePath() . DIRECTORY_SEPARATOR . Builder::TEMPLATE_CLASSNAME_PREFIX . "*");
}
public function purge() : void
{
foreach($this->getFilelist() as $dir)
{
dump($dir);
}
}
}