Controller/Adminhtml/Variable/Template.php
public function execute()
    {

        $template = $this->_initTemplate();

        try {
            $parts = $this->emailConfig->parseTemplateIdParts(self::INVOICE_TMEPLTE_ID);
            $templateId = $parts['templateId'];
            $theme = $parts['theme'];

            if ($theme) {
                $template->setForcedTheme($templateId, $theme);
            }

            $template->setForcedArea($templateId);

            $template->loadDefault($templateId);
            $template->setData('orig_template_code', $templateId);
            $template->setData(
                'template_variables',
                Zend_Json::encode($template->getVariablesOptionArray(true))
            );

            $templateBlock = $this->_view->getLayout()->createBlock(
                \Magento\Email\Block\Adminhtml\Template\Edit::class
            );
            $template->setData(
                'orig_template_currently_used_for',
                $templateBlock->getCurrentlyUsedForPaths(false)
            );

            $this->getResponse()->representJson(
                $this->jsonHelperData
                    ->jsonEncode($template->getData())
            );
        } catch (Exception $e) {
            $this->messageManager->addErrorMessage($e, 'There was a problem:' . $e->getMessage());
        }

        $customVariables = $this->variableModel
            ->getVariablesOptionArray(true);
        $storeContactVariables = $this->variablesFacrory->create()->toOptionArray(true);
        /** @var Json $resultJson */
        $resultJson = $this->resultJsonFactory->create();
        return $resultJson->setData([
            $storeContactVariables,
            $customVariables,
            $template->getVariablesOptionArray(true)
        ]);
    }
public function execute()
    {

        $template = $this->_initTemplate();

        try {
            $parts = $this->emailConfig->parseTemplateIdParts(self::INVOICE_TMEPLTE_ID);
            $templateId = $parts['templateId'];
            $theme = $parts['theme'];

            if ($theme) {
                $template->setForcedTheme($templateId, $theme);
            }

            $template->setForcedArea($templateId);

            $template->loadDefault($templateId);
            $template->setData('orig_template_code', $templateId);
            $template->setData(
                'template_variables',
                Zend_Json::encode($template->getVariablesOptionArray(true))
            );

            $templateBlock = $this->_view->getLayout()->createBlock(
                \Magento\Email\Block\Adminhtml\Template\Edit::class
            );
            $template->setData(
                'orig_template_currently_used_for',
                $templateBlock->getCurrentlyUsedForPaths(false)
            );

            $this->getResponse()->representJson(
                $this->jsonHelperData
                    ->jsonEncode($template->getData())
            );
        } catch (Exception $e) {
            $this->messageManager->addErrorMessage($e, 'There was a problem:' . $e->getMessage());
        }

        $customVariables = $this->variableModel
            ->getVariablesOptionArray(true);
        $storeContactVariables = $this->variablesFacrory->create()->toOptionArray(true);
        /** @var Json $resultJson */
        $resultJson = $this->resultJsonFactory->create();
        return $resultJson->setData([
            $storeContactVariables,
            $customVariables,
            $template->getVariablesOptionArray(true)
        ]);
    }
public function execute ( ) { $ template = $ this -> _initTemplate ( ) ; try { $ parts = $ this -> emailConfig -> parseTemplateIdParts ( self :: INVOICE_TMEPLTE_ID ) ; $ templateId = $ parts [ 'templateId' ] ; $ theme = $ parts [ 'theme' ] ; if ( $ theme ) { $ template -> setForcedTheme ( $ templateId , $ theme ) ; } $ template -> setForcedArea ( $ templateId ) ; $ template -> loadDefault ( $ templateId ) ; $ template -> setData ( 'orig_template_code' , $ templateId ) ; $ template -> setData ( 'template_variables' , Zend_Json :: encode ( $ template -> getVariablesOptionArray ( true ) ) ) ; $ templateBlock = $ this -> _view -> getLayout ( ) -> createBlock ( \ Magento \ Email \ Block \ Adminhtml \ Template \ Edit :: class ) ; $ template -> setData ( 'orig_template_currently_used_for' , $ templateBlock -> getCurrentlyUsedForPaths ( false ) ) ; $ this -> getResponse ( ) -> representJson ( $ this -> jsonHelperData -> jsonEncode ( $ template -> getData ( ) ) ) ; } catch ( Exception $ e ) { $ this -> messageManager -> addErrorMessage ( $ e , 'There was a problem:' . $ e -> getMessage ( ) ) ; } $ customVariables = $ this -> variableModel -> getVariablesOptionArray ( true ) ; $ storeContactVariables = $ this -> variablesFacrory -> create ( ) -> toOptionArray ( true ) ; /** @var Json $resultJson */ $ resultJson = $ this -> resultJsonFactory -> create ( ) ; return $ resultJson -> setData ( [ $ storeContactVariables , $ customVariables , $ template -> getVariablesOptionArray ( true ) ] ) ; }
WYSIWYG Plugin Action

@return Json
WYSIWYG Plugin Action