팁/튜토리얼

코어의 lang을 수정하고 싶은데, 코어 수정은 피하고 싶은 경우 땜빵으로 사용할 수 있는 방법입니다.

 

아래와 같이 moduleHandler.proc after 트리거를 걸어주고요

<eventHandler after="moduleHandler.proc" class="Controllers\EventHandlers" method="afterModuleProc" />

 

아래와 같이 컨트롤러에 코드를 넣어주면 됩니다.

아래 예시는 신고목록을 원하는대로 수정하는 예시 코드입니다.

 

public function afterModuleProc()
{
  $oLang = Lang::getInstance('ko');

  $declare_list = [
    '예시 신고 목록1',
    '예시 신고 목록2',
    // ...
  ];

  $list = [];
  foreach ($declare_list as $reason) {
    $list[$reason] = $reason;
  }

  $list['others'] = '기타(직접작성)';

  $oLang->set('improper_document_reasons', $list); // $lang->improper_document_reasons 수정
  $oLang->set('improper_comment_reasons', $list);
}

 

다만 lang이 사용되는 위치에 따라서, 적용이 될때도? 안될때도? 있더라고요.

전역적으로 사용한다면 위 예시를 차용하되, 지엽적으로 사용한다면 호출 전에 명시적으로 넣어주는 것을 권장합니다.

리버스 Lv. 7
모듈만드는 대학생입니다.
https://potatosoft.kr

댓글 0