serializer = $serializer; $this->captchaHelper = $captchaHelper; } /** * {@inheritdoc} */ public function execute() { $formId = $this->getRequest()->getPost('formId'); $captchaModel = $this->captchaHelper->getCaptcha($formId); $this->_view->getLayout()->createBlock( $captchaModel->getBlockName() )->setFormId( $formId )->setIsAjax( true )->toHtml(); $this->getResponse()->representJson($this->serializer->serialize(['imgSrc' => $captchaModel->getImgSrc()])); $this->_actionFlag->set('', self::FLAG_NO_POST_DISPATCH, true); } /** * Check if user has permissions to access this controller * * @return bool */ protected function _isAllowed() { return true; } }