Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
feat(installer): updated code for reset twig cache (Issue #225)
Browse files Browse the repository at this point in the history
  • Loading branch information
DIOHz0r committed Nov 28, 2017
1 parent bcae847 commit c8b4cfb
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions install/installer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,33 @@ public function createDirectories() {
}

// Create cache directory for the template engine
if (! file_exists(FLYVEMDM_TEMPLATE_CACHE_PATH)) {
if (! mkdir(FLYVEMDM_TEMPLATE_CACHE_PATH, 0770, true)) {
$this->migration->displayWarning("Cannot create " . FLYVEMDM_TEMPLATE_CACHE_PATH . " directory");
self::deleteDirectory(FLYVEMDM_TEMPLATE_CACHE_PATH);
if (!mkdir(FLYVEMDM_TEMPLATE_CACHE_PATH, 0770, true)) {
$this->migration->displayWarning("Cannot create " . FLYVEMDM_TEMPLATE_CACHE_PATH . " directory");
}
}

/**
* delete a directory recursive
* @param string $dir
* @return bool
*/
public static function deleteDirectory($dir) {
if (!file_exists($dir)) {
return true;
}
if (!is_dir($dir)) {
return unlink($dir);
}
foreach (scandir($dir) as $item) {
if ($item == '.' || $item == '..') {
continue;
}
if (!self::deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {
return false;
}
}
return rmdir($dir);
}

public static function getCurrentVersion() {
Expand Down

0 comments on commit c8b4cfb

Please sign in to comment.