Skip to content

Commit 8e48b9e

Browse files
authored
fix #1790 Api/ThemeFilesController::add() で getFullpathを利用 (#1812)
Co-authored-by: Đỗ Văn Hùng <HungDV2022>
1 parent 5ab61e3 commit 8e48b9e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

plugins/bc-theme-file/src/Controller/Api/ThemeFilesController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public function add(ThemeFilesServiceInterface $service)
3434
$this->request->allowMethod(['post', 'put']);
3535

3636
try {
37-
$form = $service->create($this->getRequest()->getData());
37+
$data = $this->getRequest()->getData();
38+
$data['fullpath'] = $service->getFullpath($data['theme'], $data['type'], $data['path']);
39+
$form = $service->create($data);
3840
$entity = $service->get($form->getData('fullpath'));
3941
$message = __d('baser', 'ファイル「{0}」を作成しました。', $entity->name);
4042
} catch (BcFormFailedException $e) {

plugins/bc-theme-file/tests/TestCase/Controller/Api/ThemeFilesControllerTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ public function test_add()
6969
//POSTデータを生成
7070
$fullpath = BASER_PLUGINS . 'BcThemeSample' . '/templates/layout/';
7171
$data = [
72-
'mode' => 'create',
73-
'fullpath' => $fullpath,
72+
'theme' => 'BcThemeSample',
73+
'type' => 'layout',
74+
'path' => '',
7475
'base_name' => 'base_name_1',
7576
'contents' => 'this is a content!',
7677
'ext' => 'php',

0 commit comments

Comments
 (0)