Skip to content

Commit

Permalink
fix baserproject#3828 【カスタムコンテンツ】ファイル項目を含むエントリーをプレビュー時にエラーとなる
Browse files Browse the repository at this point in the history
  • Loading branch information
dovanhung committed Sep 25, 2024
1 parent f827f35 commit 44f412b
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use BaserCore\Utility\BcContainerTrait;
use BaserCore\Utility\BcSiteConfig;
use BaserCore\Utility\BcUtil;
use BcCcFile\Utility\BcCcFileUtil;
use BcCustomContent\Model\Entity\CustomContent;
use BcCustomContent\Service\CustomContentsService;
use BcCustomContent\Service\CustomContentsServiceInterface;
Expand Down Expand Up @@ -238,10 +239,17 @@ public function setupPreviewForView(Controller $controller): void
$customContent = $this->ContentsService->get($request->getParam('entityId'));
$controller->set($this->getViewVarsForView($customContent, $entryId, true));
$customEntry = $controller->viewBuilder()->getVar('customEntry');

if (!$this->EntriesService->CustomEntries->hasBehavior('BaserCore.BcUpload')) {
BcCcFileUtil::setupUploader($customContent->custom_table_id);
}
// $events = BcUtil::offEvent($this->EntriesService->CustomEntries->getEventManager(), 'Model.beforeMarshal');
$entity = $this->EntriesService->CustomEntries->patchEntity(
$customEntry?? $this->EntriesService->CustomEntries->newEmptyEntity(),
$request->getData()
$customEntry ?? $this->EntriesService->CustomEntries->newEmptyEntity(),
$this->EntriesService->CustomEntries->saveTmpFiles($request->getData(), mt_rand(0, 99999999))->toArray()
);
// BcUtil::onEvent($this->EntriesService->CustomEntries->getEventManager(), 'Model.beforeMarshal', $events);

$entity = $this->EntriesService->CustomEntries->decodeRow($entity);
$controller->set(['customEntry' => $entity]);

Expand Down

0 comments on commit 44f412b

Please sign in to comment.