- WIP on RAW token

- WIP on caching interface
- Work done on easing template rendering for the controller
This commit is contained in:
mcndave committed 2019-10-04 08:38:11 -04:00
1 parent f8e3dbd60f
commit bcd49884fc
37 files changed
+381 -107

No files matched your search

+23 -4
View File
@@ -2,16 +2,16 @@
namespace Picea\Caching;
class Opcache {
class Opcache implements Cache {
protected string $cachePath = "";
public function __construct(string $cachePath)
public function __construct(?string $cachePath = null)
{
$this->cachePath = $cachePath;
$this->cachePath = $cachePath ?? sys_get_temp_dir();
}
public function loadFile(string $fileName) : bool
public function handle(string $fileName) : bool
{
if ( file_exists($path = $this->filePath($fileName)) ) {
require_once($path);
@@ -23,6 +23,8 @@ class Opcache {
public function saveFile(string $fileName, string $content) : bool
{
$this->validateCachePath();
file_put_contents($this->filePath($fileName), $content);
return false;
@@ -32,4 +34,21 @@ class Opcache {
{
return $this->cachePath . $fileName;
}
protected function validateCachePath() : bool
{
if ( ! file_exists($this->cachePath) ) {
mkdir($this->cachePath, 0750, true);
}
if ( ! is_writeable($this->cachePath) ) {
throw new \RuntimeException(
sprintf("Given cache path `%s` is not writeable by `%s`", $this->cachePath, static::class)
);
return false;
}
return true;
}
}