public function preProcess(
        \TYPO3\CMS\Backend\View\PageLayoutView &$parentObject,
        &$drawItem,
        &$headerContent,
        &$itemContent,
        array &$row
    ) {
        $this->settingsService = GeneralUtility::makeInstance(SettingsService::class);
        $this->extSettings = $this->settingsService->get();

        // only render special backend preview if it is a mask element
        if (substr($row['CType'], 0, 4) === "mask") {
            $elementKey = substr($row['CType'], 5);

            # fallback to prevent breaking change
            $templatePathAndFilename = MaskUtility::getTemplatePath(
                $this->extSettings,
                $elementKey,
                false,
                MaskUtility::getFileAbsFileName($this->extSettings['backend'])
            );

            if (file_exists($templatePathAndFilename)) {
                // initialize some things we need
                $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
                $this->inlineHelper = GeneralUtility::makeInstance(InlineHelper::class);
                $this->storageRepository = $this->objectManager->get(StorageRepository::class);
                $view = $this->objectManager->get(StandaloneView::class);

                // Load the backend template
                $view->setTemplatePathAndFilename($templatePathAndFilename);

                // if there are paths for layouts and partials set, add them to view
                if (!empty($this->extSettings["layouts_backend"])) {
                    $layoutRootPath = MaskUtility::getFileAbsFileName($this->extSettings["layouts_backend"]);
                    $view->setLayoutRootPaths(array($layoutRootPath));
                }
                if (!empty($this->extSettings["partials_backend"])) {
                    $partialRootPath = MaskUtility::getFileAbsFileName($this->extSettings["partials_backend"]);
                    $view->setPartialRootPaths(array($partialRootPath));
                }

                // Fetch and assign some useful variables
                $data = $this->getContentObject($row["uid"]);
                $element = $this->storageRepository->loadElement("tt_content", $elementKey);
                $view->assign("row", $row);
                $view->assign("data", $data);

                // if the elementLabel contains LLL: then translate it
                $elementLabel = $element["label"];
                if (GeneralUtility::isFirstPartOfStr($elementLabel, 'LLL:')) {
                    $elementLabel = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($elementLabel, "mask");
                }

                // Render everything
                $content = $view->render();
                $editElementUrlParameters = [
                    'edit' => [
                        'tt_content' => [
                            $row['uid'] => 'edit'
                        ]
                    ],
                    'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
                ];
                $editElementUrl = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('record_edit',
                    $editElementUrlParameters);
                $headerContent = '<strong><a href="' . $editElementUrl . '">' . $elementLabel . '</a></strong><br>';
                $itemContent .= '<div style="display:block; padding: 10px 0 4px 0px;border-top: 1px solid #CACACA;margin-top: 6px;" class="content_preview_' . $elementKey . '">';
                $itemContent .= $content;
                $itemContent .= '</div>';
                $drawItem = false;
            }
        }
    }
public function preProcess(
        \TYPO3\CMS\Backend\View\PageLayoutView &$parentObject,
        &$drawItem,
        &$headerContent,
        &$itemContent,
        array &$row
    ) {
        $this->settingsService = GeneralUtility::makeInstance(SettingsService::class);
        $this->extSettings = $this->settingsService->get();

        // only render special backend preview if it is a mask element
        if (substr($row['CType'], 0, 4) === "mask") {
            $elementKey = substr($row['CType'], 5);

            # fallback to prevent breaking change
            $templatePathAndFilename = MaskUtility::getTemplatePath(
                $this->extSettings,
                $elementKey,
                false,
                MaskUtility::getFileAbsFileName($this->extSettings['backend'])
            );

            if (file_exists($templatePathAndFilename)) {
                // initialize some things we need
                $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
                $this->inlineHelper = GeneralUtility::makeInstance(InlineHelper::class);
                $this->storageRepository = $this->objectManager->get(StorageRepository::class);
                $view = $this->objectManager->get(StandaloneView::class);

                // Load the backend template
                $view->setTemplatePathAndFilename($templatePathAndFilename);

                // if there are paths for layouts and partials set, add them to view
                if (!empty($this->extSettings["layouts_backend"])) {
                    $layoutRootPath = MaskUtility::getFileAbsFileName($this->extSettings["layouts_backend"]);
                    $view->setLayoutRootPaths(array($layoutRootPath));
                }
                if (!empty($this->extSettings["partials_backend"])) {
                    $partialRootPath = MaskUtility::getFileAbsFileName($this->extSettings["partials_backend"]);
                    $view->setPartialRootPaths(array($partialRootPath));
                }

                // Fetch and assign some useful variables
                $data = $this->getContentObject($row["uid"]);
                $element = $this->storageRepository->loadElement("tt_content", $elementKey);
                $view->assign("row", $row);
                $view->assign("data", $data);

                // if the elementLabel contains LLL: then translate it
                $elementLabel = $element["label"];
                if (GeneralUtility::isFirstPartOfStr($elementLabel, 'LLL:')) {
                    $elementLabel = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($elementLabel, "mask");
                }

                // Render everything
                $content = $view->render();
                $editElementUrlParameters = [
                    'edit' => [
                        'tt_content' => [
                            $row['uid'] => 'edit'
                        ]
                    ],
                    'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
                ];
                $editElementUrl = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('record_edit',
                    $editElementUrlParameters);
                $headerContent = '<strong><a href="' . $editElementUrl . '">' . $elementLabel . '</a></strong><br>';
                $itemContent .= '<div style="display:block; padding: 10px 0 4px 0px;border-top: 1px solid #CACACA;margin-top: 6px;" class="content_preview_' . $elementKey . '">';
                $itemContent .= $content;
                $itemContent .= '</div>';
                $drawItem = false;
            }
        }
    }
public function preProcess ( \ TYPO3 \ CMS \ Backend \ View \ PageLayoutView & $ parentObject , & $ drawItem , & $ headerContent , & $ itemContent , array & $ row ) { $ this -> settingsService = GeneralUtility :: makeInstance ( SettingsService :: class ) ; $ this -> extSettings = $ this -> settingsService -> get ( ) ; // only render special backend preview if it is a mask element if ( substr ( $ row [ 'CType' ] , 0 , 4 ) === "mask" ) { $ elementKey = substr ( $ row [ 'CType' ] , 5 ) ; # fallback to prevent breaking change $ templatePathAndFilename = MaskUtility :: getTemplatePath ( $ this -> extSettings , $ elementKey , false , MaskUtility :: getFileAbsFileName ( $ this -> extSettings [ 'backend' ] ) ) ; if ( file_exists ( $ templatePathAndFilename ) ) { // initialize some things we need $ this -> objectManager = GeneralUtility :: makeInstance ( ObjectManager :: class ) ; $ this -> inlineHelper = GeneralUtility :: makeInstance ( InlineHelper :: class ) ; $ this -> storageRepository = $ this -> objectManager -> get ( StorageRepository :: class ) ; $ view = $ this -> objectManager -> get ( StandaloneView :: class ) ; // Load the backend template $ view -> setTemplatePathAndFilename ( $ templatePathAndFilename ) ; // if there are paths for layouts and partials set, add them to view if ( ! empty ( $ this -> extSettings [ "layouts_backend" ] ) ) { $ layoutRootPath = MaskUtility :: getFileAbsFileName ( $ this -> extSettings [ "layouts_backend" ] ) ; $ view -> setLayoutRootPaths ( array ( $ layoutRootPath ) ) ; } if ( ! empty ( $ this -> extSettings [ "partials_backend" ] ) ) { $ partialRootPath = MaskUtility :: getFileAbsFileName ( $ this -> extSettings [ "partials_backend" ] ) ; $ view -> setPartialRootPaths ( array ( $ partialRootPath ) ) ; } // Fetch and assign some useful variables $ data = $ this -> getContentObject ( $ row [ "uid" ] ) ; $ element = $ this -> storageRepository -> loadElement ( "tt_content" , $ elementKey ) ; $ view -> assign ( "row" , $ row ) ; $ view -> assign ( "data" , $ data ) ; // if the elementLabel contains LLL: then translate it $ elementLabel = $ element [ "label" ] ; if ( GeneralUtility :: isFirstPartOfStr ( $ elementLabel , 'LLL:' ) ) { $ elementLabel = \ TYPO3 \ CMS \ Extbase \ Utility \ LocalizationUtility :: translate ( $ elementLabel , "mask" ) ; } // Render everything $ content = $ view -> render ( ) ; $ editElementUrlParameters = [ 'edit' => [ 'tt_content' => [ $ row [ 'uid' ] => 'edit' ] ] , 'returnUrl' => GeneralUtility :: getIndpEnv ( 'REQUEST_URI' ) ] ; $ editElementUrl = \ TYPO3 \ CMS \ Backend \ Utility \ BackendUtility :: getModuleUrl ( 'record_edit' , $ editElementUrlParameters ) ; $ headerContent = '<strong><a href="' . $ editElementUrl . '">' . $ elementLabel . '</a></strong><br>' ; $ itemContent .= '<div style="display:block; padding: 10px 0 4px 0px;border-top: 1px solid #CACACA;margin-top: 6px;" class="content_preview_' . $ elementKey . '">' ; $ itemContent .= $ content ; $ itemContent .= '</div>' ; $ drawItem = false ; } } }
Preprocesses the preview rendering of a content element.

@param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
@param boolean $drawItem Whether to draw the item using the default functionalities
@param string $headerContent Header content
@param string $itemContent Item content
@param array $row Record row of tt_content
@return void
Preprocesses the preview rendering of a content element .