2017-12-15 5 views
0

Typo3 8.7에서 사용자 정의 컨텐츠 요소에 대한 BackendPreview에서 다음 코드를 사용하여 컨텐츠 클래스를 얻으려고합니다.Typo3 BackendPreview get cObj throws : null에 enableFields()를 호출합니다.

  $conf = array(
      'tables' => 'tt_content', 
      'source' => $uid, 
      'dontCheckPid' => 1 
     ); 

     $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class); 
     $result = $this->objectManager->get(RecordsContentObject::class)->render($conf); 

frontendContext에서이 작업을 수행하면 예상대로 cObj가 반환되지만 BE 컨텍스트에서는 typo3에서 "null의 멤버 함수 enableFields() 호출"예외가 발생합니다.

나는 configurationManager를 수동으로 초기화하려고했지만 효과가 없습니다.

누구나 아이디어가 있으십니까?

답변

0

(TypoScript 렌더링을 담당하는) ContentObjectRenderer는 TSFE (TypoScriptFrontendController)가 필요하고 FE 컨텍스트가 아니고 BE 컨텍스트에 있지 않으므로 초기화되지 않습니다.

이론적으로 이론을 위장 할 수는 있지만 성능은 떨어지지 만 권장하지는 않습니다.

https://docs.typo3.org/typo3cms/extensions/fluid_styled_content/7.6/AddingYourOwnContentElements/Index.html

: 당신이 privew을하고 싶은 경우

,이 approche를 사용