Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Refresh.php
Go to the documentation of this file.
1 <?php
10 
12 {
16  protected $serializer;
17 
21  protected $captchaHelper;
22 
29  public function __construct(
30  \Magento\Backend\App\Action\Context $context,
31  \Magento\Captcha\Helper\Data $captchaHelper,
32  \Magento\Framework\Serialize\Serializer\Json $serializer
33  ) {
34  parent::__construct($context);
35  $this->serializer = $serializer;
36  $this->captchaHelper = $captchaHelper;
37  }
38 
42  public function execute()
43  {
44  $formId = $this->getRequest()->getPost('formId');
45  $captchaModel = $this->captchaHelper->getCaptcha($formId);
46  $this->_view->getLayout()->createBlock(
47  $captchaModel->getBlockName()
48  )->setFormId(
49  $formId
50  )->setIsAjax(
51  true
52  )->toHtml();
53  $this->getResponse()->representJson($this->serializer->serialize(['imgSrc' => $captchaModel->getImgSrc()]));
54  $this->_actionFlag->set('', self::FLAG_NO_POST_DISPATCH, true);
55  }
56 
62  protected function _isAllowed()
63  {
64  return true;
65  }
66 }
__construct(\Magento\Backend\App\Action\Context $context, \Magento\Captcha\Helper\Data $captchaHelper, \Magento\Framework\Serialize\Serializer\Json $serializer)
Definition: Refresh.php:29