_helperData = $helperData; $this->_registry = $registry; $this->_codeHelper = $codeHelper; $this->_formHelper = $formHelper; $this->setForm($formFactory->create()); } /** * Prepare form before rendering HTML * * @return \Magento\Backend\Block\Widget\Form */ protected function _prepareForm() { $this->_formHelper->addGoogleoptimizerFields($this->getForm(), $this->_getGoogleExperiment()); return parent::_prepareForm(); } /** * Get google experiment code model * * @return \Magento\GoogleOptimizer\Model\Code|null */ protected function _getGoogleExperiment() { $entity = $this->_getEntity(); if ($entity->getId()) { return $this->_codeHelper->getCodeObjectByEntity($entity); } return null; } /** * Get Entity model * * @return \Magento\Catalog\Model\AbstractModel */ abstract protected function _getEntity(); /** * Can show tab in tabs * * @return bool */ public function canShowTab() { return $this->_helperData->isGoogleExperimentActive(); } /** * Tab is hidden * * @return bool */ public function isHidden() { return false; } }