コード例 #1
0
 /**
  * Ajax action for inline translation
  *
  * @return void
  */
 public function execute()
 {
     $translate = (array) $this->getRequest()->getPost('translate');
     try {
         $response = $this->inlineParser->processAjaxPost($translate);
     } catch (\Exception $e) {
         $response = "{error:true,message:'" . $e->getMessage() . "'}";
     }
     $this->getResponse()->representJson(json_encode($response));
     $this->_actionFlag->set('', self::FLAG_NO_POST_DISPATCH, true);
 }
コード例 #2
0
ファイル: Translate.php プロジェクト: nblair/magescotch
 /**
  * Ajax action for inline translation
  *
  * @return \Magento\Framework\Controller\Result\Json
  */
 public function executeInternal()
 {
     $translate = (array) $this->getRequest()->getPost('translate');
     /** @var \Magento\Framework\Controller\Result\Json $resultJson */
     $resultJson = $this->resultJsonFactory->create();
     try {
         $this->inlineParser->processAjaxPost($translate);
         $response = ['success' => 'true'];
     } catch (\Exception $e) {
         $response = ['error' => 'true', 'message' => $e->getMessage()];
     }
     $this->_actionFlag->set('', self::FLAG_NO_POST_DISPATCH, true);
     return $resultJson->setData($response);
 }