Skip to content

Commit

Permalink
ContentsTable::beforeSave() 調整
Browse files Browse the repository at this point in the history
ゴミ箱から戻す際にエラーとなっていた
  • Loading branch information
ryuring committed Sep 7, 2024
1 parent 1da8fd6 commit 2a38d81
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugins/baser-core/src/Model/Table/ContentsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use ArrayObject;
use Cake\Chronos\Chronos;
use Cake\Datasource\Exception\RecordNotFoundException;
use Cake\Utility\Hash;
use Cake\Core\Configure;
use Cake\ORM\TableRegistry;
Expand Down Expand Up @@ -468,7 +469,11 @@ public function getUniqueName($name, $parentId, $contentId = null)
public function beforeSave(EventInterface $event, EntityInterface $entity, ArrayObject $options)
{
if (!empty($entity->id)) {
$this->beforeSaveParentId = $this->get($entity->id)->parent_id;
try {
$this->beforeSaveParentId = $this->get($entity->id)->parent_id;
} catch (RecordNotFoundException) {
$this->beforeSaveParentId = $this->getTrash($entity->id)->parent_id;
}
}
if (!empty($entity->name)) {
$entity->name = $this->urlEncode(mb_substr(rawurldecode($entity->name), 0, 230, 'UTF-8'));
Expand Down

0 comments on commit 2a38d81

Please sign in to comment.