Fix for #115, theme css subdir deleted on publish
Patch for a bug that was deleteting the subdirectories of the theme css folder holding additional theme assets when being published and tested in the theme kit. also removed an unneccessary helper script and organized directory actions in their own helper file to keep it all tidy
This commit is contained in:
parent
fb3aff6c85
commit
68469d958b
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…
Reference in a new issue