인터셉트 문의
유저 이미지
분쟁제로
- 2017.11.14
- 조회수 419
- 댓글수 1
별도 플러그인 설치시 게시판 조회수 증가 무조건 되도록 만들고자 합니다.
원래 함수부분은
public function incrementReadCount(Board $board, UserInterface $user)
{
if ($this->readCounter->has($board->id, $user) === false) {
$this->readCounter->add($board->id, $user);
}
$board->read_count = $this->readCounter->getPoint($board->id);
$board->timestamps = false;
$board->save();
}
이렇습니다.
인터셉트로
intercept(
'\Xpressengine\Plugins\Board\Handler@incrementReadCount',
'boonzero_board_skin@readcount',
function($func, Board $board, UserInterface $user) {
$this->readCounter->add($board->id, $user); // 조회수 한번 더 증가 <<<<<< 이런식
$func($board, $user);
}
);
근데 대체할 메소드 안에 $this 가 있는 경우 어떻게 해야할지요?
인터셉트로 함수를 대체하려면 그 인스턴스에 접근할 수 있어야 할것 같은데.......
감사합니다
0개 댓글