shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

cache.php (1907B)


      1 <?php
      2 /*
      3  *  location: admin/model/extension/d_opencart_patch/cache.php
      4  *  
      5  *  This will help you refreshing the twig cache on update of an extension. 
      6  */
      7 
      8 class ModelExtensionDOpencartPatchCache extends Model {
      9 
     10     public function clearCache() {
     11 
     12         $files = glob(DIR_CACHE . 'cache.*');
     13 
     14         if ($files) {
     15             foreach ($files as $file) {
     16                 if (file_exists($file)) {
     17                     unlink($file);
     18                 }
     19             }
     20         }
     21 
     22         return true;
     23     }
     24 
     25     public function clearTwig() {
     26         
     27         $directories = glob(DIR_CACHE . '*', GLOB_ONLYDIR);
     28 
     29         if ($directories) {
     30             foreach ($directories as $directory) {
     31                 $files = glob($directory . '/*');
     32                 
     33                 foreach ($files as $file) { 
     34                     if (is_file($file)) {
     35                         unlink($file);
     36                     }
     37                 }
     38 
     39                 if (is_dir($directory) && is_readable($directory) && count(scandir($directory)) == 0) {
     40                     rmdir($directory);
     41                 }
     42             }
     43         }
     44                     
     45         return true;
     46     }
     47         
     48     public function clearSass() {
     49         $file = DIR_APPLICATION  . 'view/stylesheet/bootstrap.css';
     50             
     51         if (is_file($file) && is_file(DIR_APPLICATION . 'view/stylesheet/sass/_bootstrap.scss')) {
     52             unlink($file);
     53         }
     54          
     55         $files = glob(DIR_CATALOG  . 'view/theme/*/stylesheet/sass/_bootstrap.scss');
     56          
     57         foreach ($files as $file) {
     58             $file = substr($file, 0, -21) . '/bootstrap.css';
     59             
     60             if (is_file($file)) {
     61                 unlink($file);
     62             }
     63         }
     64         
     65         return true;
     66     }
     67 
     68     public function clearAll(){
     69         $this->clearCache();
     70         $this->clearTwig();
     71         $this->clearSass();
     72         return true;
     73     }
     74 }