Skip to content

Commit

Permalink
エレメント読み込みの際、処理を中断せずに、読み込み箇所にエラーを表示するように調整
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Feb 23, 2024
1 parent 3cdf03a commit a61d5d5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions plugins/baser-core/src/View/Helper/BcBaserHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use BaserCore\Model\Entity\Content;
use BaserCore\Model\Entity\Site;
use BaserCore\Model\Table\SitesTable;
use BaserCore\Service\PagesService;
use BaserCore\Service\PagesServiceInterface;
use BaserCore\Utility\BcSiteConfig;
use BcBlog\Model\Entity\BlogPost;
Expand All @@ -34,6 +33,7 @@
use Cake\Routing\Router;
use Cake\Utility\Hash;
use Cake\Utility\Inflector;
use Cake\View\Exception\MissingElementException;
use Cake\View\Helper\BreadcrumbsHelper;
use Cake\View\View;
use Cake\View\Helper;
Expand Down Expand Up @@ -323,7 +323,13 @@ public function getElement(string $name, array $data = [], array $options = [])
$options = ($event->getResult() === null || $event->getResult() === true)? $event->getData('options') : $event->getResult();
}

$out = $this->_View->element($name, $data, $options);
$out = '';
try {
$out = $this->_View->element($name, $data, $options);
} catch (MissingElementException $e) {
echo __d('baser_core', 'エレメントテンプレート「{0}」が見つかりませんでした。', $name);
$this->log($e->getMessage());
}

// EVENT afterElement
$event = $this->dispatchLayerEvent('afterElement', [
Expand Down

0 comments on commit a61d5d5

Please sign in to comment.