Replaced Moment with Carbon #84
4 changed files with 47 additions and 32 deletions
38
app/Helpers/DirectoryHelpers.php
Normal file
38
app/Helpers/DirectoryHelpers.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
function delete_directory($dirPath)
|
||||
{
|
||||
if (is_dir($dirPath)) {
|
||||
$objects = new DirectoryIterator($dirPath);
|
||||
foreach ($objects as $object) {
|
||||
if (!$object->isDot()) {
|
||||
if ($object->isDir()) {
|
||||
delete_directory($object->getPathname());
|
||||
} else {
|
||||
unlink($object->getPathname());
|
||||
}
|
||||
}
|
||||
}
|
||||
rmdir($dirPath);
|
||||
} else {
|
||||
throw new Exception(__FUNCTION__ . '(dirPath): dirPath is not a directory!');
|
||||
}
|
||||
}
|
||||
|
||||
function copy_directory($src, $dst)
|
||||
{
|
||||
if (file_exists($dst)) {
|
||||
rrmdir($dst);
|
||||
}
|
||||
if (is_dir($src)) {
|
||||
mkdir($dst);
|
||||
$files = scandir($src);
|
||||
foreach ($files as $file) {
|
||||
if ($file != "." && $file != "..") {
|
||||
copy_directory("$src/$file", "$dst/$file");
|
||||
}
|
||||
}
|
||||
} elseif (file_exists($src)) {
|
||||
copy($src, $dst);
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
use App\Services\ContentService;
|
||||
|
||||
function sorter()
|
||||
{
|
||||
$content = new ContentService();
|
||||
$pages = $content->loadAllPages();
|
||||
echo(count($pages));
|
||||
}
|
|
@ -62,22 +62,3 @@ function createAppKey()
|
|||
{
|
||||
return 'base64:' . base64_encode(Encrypter::generateKey(config('app.cipher')));
|
||||
}
|
||||
|
||||
function delete_directory($dirPath)
|
||||
{
|
||||
if (is_dir($dirPath)) {
|
||||
$objects = new DirectoryIterator($dirPath);
|
||||
foreach ($objects as $object) {
|
||||
if (!$object->isDot()) {
|
||||
if ($object->isDir()) {
|
||||
delete_directory($object->getPathname());
|
||||
} else {
|
||||
unlink($object->getPathname());
|
||||
}
|
||||
}
|
||||
}
|
||||
rmdir($dirPath);
|
||||
} else {
|
||||
throw new Exception(__FUNCTION__ . '(dirPath): dirPath is not a directory!');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,11 +86,17 @@ class AssetService
|
|||
copy($file, $cssPath . $path[6]);
|
||||
} else {
|
||||
// if there is a type/font folder, move it
|
||||
|
||||
$typePath = explode('/', $file);
|
||||
if (is_dir($cssPath . $typePath[6])) {
|
||||
delete_directory($cssPath . $typePath[6]);
|
||||
$src = '../content/themes/' . $this->currentTheme . '/assets/css/' . $typePath[6];
|
||||
$dst = $cssPath . $typePath[6];
|
||||
if (is_dir($dst)) {
|
||||
delete_directory($dst);
|
||||
copy_directory($src, $dst);
|
||||
} else {
|
||||
copy_directory($src, $dst);
|
||||
}
|
||||
rename($file, $cssPath . $typePath[6]);
|
||||
//rename($file, $cssPath . $typePath[6]);
|
||||
}
|
||||
}
|
||||
$newjs = glob('../content/themes/' . $this->currentTheme . '/assets/scripts/*');
|
||||
|
|
Loading…
Add table
Reference in a new issue