Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Translate.php
Go to the documentation of this file.
1 <?php
8 
10 
12 {
16  protected $inlineParser;
17 
21  protected $resultJsonFactory;
22 
26  const ADMIN_RESOURCE = 'Magento_Backend::content_translation';
27 
33  public function __construct(
34  Action\Context $context,
35  \Magento\Framework\Translate\Inline\ParserInterface $inlineParser,
36  \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
37  ) {
38  parent::__construct($context);
39  $this->resultJsonFactory = $resultJsonFactory;
40  $this->inlineParser = $inlineParser;
41  }
42 
48  public function execute()
49  {
50  $translate = (array)$this->getRequest()->getPost('translate');
51 
53  $resultJson = $this->resultJsonFactory->create();
54  try {
55  $this->inlineParser->processAjaxPost($translate);
56  $response = ['success' => 'true'];
57  } catch (\Exception $e) {
58  $response = ['error' => 'true', 'message' => $e->getMessage()];
59  }
60 
61  $this->_actionFlag->set('', self::FLAG_NO_POST_DISPATCH, true);
62  return $resultJson->setData($response);
63  }
64 }
$response
Definition: 404.php:11
__construct(Action\Context $context, \Magento\Framework\Translate\Inline\ParserInterface $inlineParser, \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory)
Definition: Translate.php:33