diff --git a/plugins/bc-theme-file/src/Form/ThemeFolderForm.php b/plugins/bc-theme-file/src/Form/ThemeFolderForm.php index 1050b6fde1..1f17e5be22 100644 --- a/plugins/bc-theme-file/src/Form/ThemeFolderForm.php +++ b/plugins/bc-theme-file/src/Form/ThemeFolderForm.php @@ -11,7 +11,7 @@ namespace BcThemeFile\Form; -use Cake\Filesystem\Folder; +use BaserCore\Utility\BcFolder; use Cake\Form\Form; use Cake\Form\Schema; use BaserCore\Annotation\UnitTest; @@ -50,13 +50,13 @@ protected function _buildSchema(Schema $schema): Schema */ protected function _execute(array $data): bool { - $folder = new Folder(); + $folder = new BcFolder($data['fullpath'] . DS . $data['name'] . DS); if($data['mode'] === 'create') { - return $folder->create($data['fullpath'] . DS . $data['name'] . DS, 0777); + return $folder->create(); } elseif($data['mode'] === 'update') { $newPath = dirname($data['fullpath']) . DS . $data['name'] . DS; if($newPath === $data['fullpath']) return true; - return $folder->move($newPath, ['from' => $data['fullpath'], 'chmod' => 0777, 'skip' => ['_notes']]); + return $folder->move($data['fullpath'], $newPath); } return false; } diff --git a/plugins/bc-theme-file/src/Service/ThemeFoldersService.php b/plugins/bc-theme-file/src/Service/ThemeFoldersService.php index ab8a0bee1a..801245329a 100644 --- a/plugins/bc-theme-file/src/Service/ThemeFoldersService.php +++ b/plugins/bc-theme-file/src/Service/ThemeFoldersService.php @@ -22,7 +22,6 @@ use BcThemeFile\Form\ThemeFolderForm; use BcThemeFile\Model\Entity\ThemeFolder; use Cake\Core\Plugin; -use Cake\Filesystem\Folder; /** * ThemeFoldersService @@ -210,12 +209,8 @@ public function copy(string $fullpath) } $newPath .= '_copy'; } - $folder = new Folder(); - $result = $folder->copy($newPath, [ - 'from' => $fullpath, - 'chmod' => 0777, - 'skip' => ['_notes' - ]]); + $folder = new BcFolder($fullpath); + $result = $folder->copy($fullpath, $newPath); $folder = null; if ($result) { return $newEntity; @@ -302,9 +297,9 @@ public function copyToTheme(array $params) } else { $themePath = Plugin::templatePath($theme) . $params['path'] . DS; } - $folder = new Folder(); - $folder->create(dirname($themePath), 0777); - if ($folder->copy($themePath, ['from' => $params['fullpath'], 'chmod' => 0777, 'skip' => ['_notes']])) { + $folder = new BcFolder(dirname($themePath)); + $folder->create(); + if ($folder->copy($params['fullpath'], $themePath)) { return str_replace(ROOT, '', $themePath); } else { return false; diff --git a/plugins/bc-theme-file/tests/TestCase/Controller/Api/Admin/ThemeFoldersControllerTest.php b/plugins/bc-theme-file/tests/TestCase/Controller/Api/Admin/ThemeFoldersControllerTest.php index 2467784eff..87a1609b55 100644 --- a/plugins/bc-theme-file/tests/TestCase/Controller/Api/Admin/ThemeFoldersControllerTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Controller/Api/Admin/ThemeFoldersControllerTest.php @@ -14,7 +14,7 @@ use BaserCore\Test\Factory\SiteFactory; use BaserCore\Test\Factory\UserFactory; use BaserCore\TestSuite\BcTestCase; -use Cake\Filesystem\Folder; +use BaserCore\Utility\BcFolder; use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; class ThemeFoldersControllerTest extends BcTestCase @@ -58,7 +58,7 @@ public function tearDown(): void public function test_batch() { $fullpath = BASER_PLUGINS . 'BcThemeSample' . '/templates/layout/'; - (new Folder())->create($fullpath . 'delete_folder', 0777); + (new BcFolder($fullpath . 'delete_folder'))->create(); //APIをコール $this->post('/baser/api/admin/bc-theme-file/theme_folders/batch.json?token=' . $this->accessToken, [ @@ -176,7 +176,7 @@ public function test_delete() { //テストテーマフォルダを作成 $fullpath = BASER_PLUGINS . 'BcThemeSample' . '/templates/layout/'; - (new Folder())->create($fullpath . 'delete_folder', 0777); + (new BcFolder($fullpath . 'delete_folder'))->create(); //Postデータを生成 $data = [ 'theme' => 'BcThemeSample', @@ -211,7 +211,7 @@ public function test_copy() { //テストテーマフォルダを作成 $fullpath = BASER_PLUGINS . 'BcThemeSample' . '/templates/layout/'; - (new Folder())->create($fullpath . 'new_folder', 0777); + (new BcFolder($fullpath . 'new_folder'))->create(); //Postデータを生成 $data = [ 'theme' => 'BcThemeSample', diff --git a/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php b/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php index d044057764..84469019f2 100644 --- a/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php @@ -14,8 +14,8 @@ use BaserCore\Test\Factory\SiteFactory; use BaserCore\Test\Factory\UserFactory; use BaserCore\TestSuite\BcTestCase; +use BaserCore\Utility\BcFolder; use BcThemeFile\Service\ThemeFoldersService; -use Cake\Filesystem\Folder; /** * ThemeFoldersServiceTest @@ -147,7 +147,7 @@ public function test_delete() { //テストテーマフォルダを作成 $fullpath = BASER_PLUGINS . 'BcThemeSample' . '/templates/layout'; - (new Folder())->create($fullpath . DS . 'delete_folder', 0777); + (new BcFolder($fullpath . DS . 'delete_folder'))->create(); $rs = $this->ThemeFoldersService->delete($fullpath . DS . 'delete_folder'); //戻る値を確認 $this->assertTrue($rs); @@ -162,7 +162,7 @@ public function test_copy() { //テストテーマフォルダを作成 $fullpath = BASER_PLUGINS . 'BcThemeSample/templates/layout/'; - (new Folder())->create($fullpath . 'new_folder', 0777); + (new BcFolder($fullpath . 'new_folder'))->create(); //対象のメソッドを確認 $rs = $this->ThemeFoldersService->copy($fullpath . 'new_folder'); @@ -187,8 +187,8 @@ public function test_batch() { //テストテーマフォルダパス $fullpath = BASER_PLUGINS . 'BcThemeSample/templates/layout'; - (new Folder())->create($fullpath . DS . 'folder_1', 0777); - (new Folder())->create($fullpath . DS . 'folder_2', 0777); + (new BcFolder($fullpath . DS . 'folder_1'))->create(); + (new BcFolder($fullpath . DS . 'folder_2'))->create(); //一括削除処理をテスト $paths = [ $fullpath . DS . 'folder_1',