Browse Source

Core\View: Add delete() method

Probably needed for a plugin system.
Visman 1 year ago
parent
commit
e096fa6965
1 changed files with 10 additions and 0 deletions
  1. 10 0
      app/Core/View.php

+ 10 - 0
app/Core/View.php

@@ -215,6 +215,16 @@ class View
         return $php;
     }
 
+    /**
+     * Удаляет файлы кэша для шаблона $name
+     */
+    public function delete(string $name): void
+    {
+        $st = \preg_replace('%\W%', '-', $name);
+
+        \array_map('\\unlink', \glob("{$this->cacheDir}/_{$st}-*.php"));
+    }
+
     /**
      * Генерирует $php файл на основе шаблона $tpl
      */