Skip to content

Commit

Permalink
コメントの修正
Browse files Browse the repository at this point in the history
  • Loading branch information
dovanhung committed Sep 28, 2023
1 parent 8937ceb commit 84001ea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 0 additions & 4 deletions plugins/bc-blog/src/Controller/Api/BlogPostsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@

use BaserCore\Controller\Api\BcApiController;
use BcBlog\Service\BlogPostsServiceInterface;
use BcBlog\View\Helper\BlogHelper;
use Cake\Datasource\Exception\RecordNotFoundException;
use Cake\Http\Exception\ForbiddenException;
use BaserCore\Annotation\UnitTest;
use BaserCore\Annotation\NoTodo;
use BaserCore\Annotation\Checked;
use Cake\View\View;

/**
* BlogPostsController
Expand Down Expand Up @@ -85,8 +83,6 @@ public function view(BlogPostsServiceInterface $service, $id)
$blogPost = $message = null;
try {
$blogPost = $service->get($id, $queryParams);
$BlogHelper = new BlogHelper(new View());
$blogPost->eye_catch = $BlogHelper->getEyeCatch($blogPost, ['output' => 'url']);
} catch (RecordNotFoundException $e) {
$this->setResponse($this->response->withStatus(404));
$message = __d('baser_core', 'データが見つかりません。');
Expand Down
8 changes: 8 additions & 0 deletions plugins/bc-blog/src/Model/Entity/BlogPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
use BaserCore\Annotation\UnitTest;
use BaserCore\Annotation\NoTodo;
use BaserCore\Annotation\Checked;
use BcBlog\View\Helper\BlogHelper;
use Cake\I18n\FrozenTime;
use Cake\ORM\Entity;
use Cake\View\View;

/**
* Class BlogPost
Expand Down Expand Up @@ -53,4 +55,10 @@ class BlogPost extends Entity
'id' => false
];

protected $_virtual = ['_eyecatch'];
protected function _get_eyecatch(){
$BlogHelper = new BlogHelper(new View());
return $BlogHelper->getEyeCatch($this, ['output' => 'url']);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function test_view()
// 戻り値を確認
$result = json_decode((string)$this->_response->getBody());
$this->assertEquals(1, $result->blogPost->id);
$this->assertTextContains('/files/blog/1/blog_posts/eye_catch.img', $result->blogPost->eye_catch);
$this->assertTextContains('/files/blog/1/blog_posts/eye_catch.img', $result->blogPost->_eyecatch);
$this->assertEquals(1, $result->blogPost->blog_content_id);

//存在しないBlogPostIDをテスト場合、
Expand Down

0 comments on commit 84001ea

Please sign in to comment.