Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FormKey.php
Go to the documentation of this file.
1 <?php
11 
17 {
21  protected $formKey;
22 
28  public function __construct(
29  \Magento\Framework\View\Element\Context $context,
30  \Magento\Framework\Data\Form\FormKey $formKey,
31  array $data = []
32  ) {
33  $this->formKey = $formKey;
34  parent::__construct($context, $data);
35  }
36 
42  public function getFormKey()
43  {
44  return $this->formKey->getFormKey();
45  }
46 
50  protected function _toHtml()
51  {
52  return '<input name="form_key" type="hidden" value="' . $this->getFormKey() . '" />';
53  }
54 }
__construct(\Magento\Framework\View\Element\Context $context, \Magento\Framework\Data\Form\FormKey $formKey, array $data=[])
Definition: FormKey.php:28