diff --git a/plugins/baser-core/src/Model/Table/ContentsTable.php b/plugins/baser-core/src/Model/Table/ContentsTable.php index 419040ce95..ea15024781 100644 --- a/plugins/baser-core/src/Model/Table/ContentsTable.php +++ b/plugins/baser-core/src/Model/Table/ContentsTable.php @@ -472,7 +472,9 @@ public function beforeSave(EventInterface $event, EntityInterface $entity, Array try { $this->beforeSaveParentId = $this->get($entity->id)->parent_id; } catch (RecordNotFoundException) { - $this->beforeSaveParentId = $this->getTrash($entity->id)->parent_id; + try { + $this->beforeSaveParentId = $this->getTrash($entity->id)->parent_id; + } catch (\Throwable) {} } } if (!empty($entity->name)) { diff --git a/plugins/baser-core/src/View/Helper/BcFormHelper.php b/plugins/baser-core/src/View/Helper/BcFormHelper.php index bd39225722..b4e9999ad2 100644 --- a/plugins/baser-core/src/View/Helper/BcFormHelper.php +++ b/plugins/baser-core/src/View/Helper/BcFormHelper.php @@ -707,7 +707,11 @@ public function editor($fieldName, $options = []) 'style' => 'width:99%;height:540px' ], $options); - if ($options['editor'] !== 'none') { + if(!$options['editor']) { + /** @var BcCkeditorHelper $bcCkeditor */ + $bcCkeditor = $this->getView()->BcCkeditor; + return $bcCkeditor->editor($fieldName, $options); + } elseif ($options['editor'] !== 'none') { [$plugin] = pluginSplit($options['editor']); if (!Plugin::isLoaded($plugin)) { $options['editor'] = 'none'; @@ -716,10 +720,6 @@ public function editor($fieldName, $options = []) [, $editor] = pluginSplit($options['editor']); $this->getView()->loadHelper($editor, ['className' => $className]); } - } elseif(!$options['editor']) { - /** @var BcCkeditorHelper $bcCkeditor */ - $bcCkeditor = $this->getView()->BcCkeditor; - return $bcCkeditor->editor($fieldName, $options); } if ($options['editor'] === 'none') { diff --git a/plugins/baser-core/tests/TestCase/Model/Table/ContentsTableTest.php b/plugins/baser-core/tests/TestCase/Model/Table/ContentsTableTest.php index 6664abf2a6..8af2bbd3f8 100644 --- a/plugins/baser-core/tests/TestCase/Model/Table/ContentsTableTest.php +++ b/plugins/baser-core/tests/TestCase/Model/Table/ContentsTableTest.php @@ -13,14 +13,13 @@ use ArrayObject; use BaserCore\Service\BcDatabaseService; +use BaserCore\Test\Factory\ContentFactory; use BaserCore\Test\Scenario\ContentsScenario; use BaserCore\Test\Scenario\InitAppScenario; use BaserCore\Test\Scenario\SitesScenario; use BaserCore\Test\Scenario\SmallSetContentsScenario; -use Cake\ORM\Entity; use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; use ReflectionClass; -use Cake\Core\Configure; use Cake\I18n\FrozenTime; use Cake\Validation\Validator; use BaserCore\Model\Entity\Content; @@ -289,11 +288,12 @@ public static function getUniqueNameDataProvider() public function testBeforeSave() { $value = "テスト"; - $data = new Entity([ + ContentFactory::make([ 'id' => 100, 'parent_id' => 6, - 'name' => $value - ]); + 'name' => $value, + ])->persist(); + $data = ContentFactory::get(100); $result = $this->Contents->dispatchEvent('Model.beforeSave', ['entity' => $data, 'options' => new ArrayObject()]); $this->assertEquals(6, $this->Contents->beforeSaveParentId); // nameフィールドがエンコードされてるかをテスト