Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DefaultCaptcha.php
Go to the documentation of this file.
1 <?php
7 
12 {
16  protected $_template = 'Magento_Captcha::default.phtml';
17 
21  protected $_captcha;
22 
26  protected $_captchaData;
27 
33  public function __construct(
34  \Magento\Framework\View\Element\Template\Context $context,
35  \Magento\Captcha\Helper\Data $captchaData,
36  array $data = []
37  ) {
38  parent::__construct($context, $data);
39  $this->_captchaData = $captchaData;
40  }
41 
47  public function getTemplate()
48  {
49  return $this->getIsAjax() ? '' : $this->_template;
50  }
51 
57  public function getRefreshUrl()
58  {
59  $store = $this->_storeManager->getStore();
60  return $store->getUrl('captcha/refresh', ['_secure' => $store->isCurrentlySecure()]);
61  }
62 
68  protected function _toHtml()
69  {
70  if ($this->getCaptchaModel()->isRequired()) {
71  $this->getCaptchaModel()->generate();
72  return parent::_toHtml();
73  }
74  return '';
75  }
76 
82  public function getCaptchaModel()
83  {
84  return $this->_captchaData->getCaptcha($this->getFormId());
85  }
86 }
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Captcha\Helper\Data $captchaData, array $data=[])