Skip to content

Commit

Permalink
Add file helper, update namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
DorsetDigital committed Jan 31, 2021
1 parent 217f9a8 commit 20b7dd0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
30 changes: 30 additions & 0 deletions src/Helper/FilesHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace DorsetDigital\SmartRedirect\Helper;

class FilesHelper
{

/**
* Recursively deletes the files in a given directory.
* With great power, comes great responsibility!
* @param $target
*/
public static function delete_files($target)
{
if (is_dir($target)) {
$files = glob($target . '*', GLOB_MARK);

foreach ($files as $file) {
self::delete_files($file);
}

if (is_dir($target)) {
rmdir($target);
}
} elseif (is_file($target)) {
unlink($target);
}
}

}
2 changes: 0 additions & 2 deletions src/Helper/MaxMindHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace DorsetDigital\SmartRedirect\Helper;


use App\Helper\FilesHelper;
use GuzzleHttp\Client;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Environment;
Expand Down

0 comments on commit 20b7dd0

Please sign in to comment.