diff --git a/Block/Footer.php b/Block/Footer.php deleted file mode 100644 index 6b787f7..0000000 --- a/Block/Footer.php +++ /dev/null @@ -1,64 +0,0 @@ -pageTypeDetector = $pageTypeDetector; - $this->scopeConfig = $context->getScopeConfig(); - parent::__construct($context, $data); - } - - /** - * Get module configuration - * - * @return array - */ - public function getConfig() - { - // If you already have a getConfig method, keep its implementation - // and add to it if needed - $config = [ - 'beacon_endpoint' => $this->scopeConfig->getValue( - 'basicrum/general/beacon_endpoint', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ) - ]; - - return $config; - } - - /** - * Get the current page type - * - * @return string - */ - public function getPageType() - { - return $this->pageTypeDetector->getPageType(); - } -} diff --git a/ViewModel/Footer.php b/ViewModel/Footer.php new file mode 100644 index 0000000..4dd6813 --- /dev/null +++ b/ViewModel/Footer.php @@ -0,0 +1,42 @@ + $this->scopeConfig->getValue( + 'basicrum/general/beacon_endpoint', + ScopeInterface::SCOPE_STORE + ) + ]; + + return $config; + } + + /** + * Get the current page type + */ + public function getPageType(): string + { + return $this->pageTypeDetector->getPageType(); + } +} diff --git a/view/frontend/layout/default.xml b/view/frontend/layout/default.xml index f32ab67..1fa358d 100644 --- a/view/frontend/layout/default.xml +++ b/view/frontend/layout/default.xml @@ -3,10 +3,14 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> - + > + + BasicRum\Analytics\ViewModel\Footer + + diff --git a/view/frontend/templates/footer.phtml b/view/frontend/templates/footer.phtml index f7ecf1d..c98dc10 100644 --- a/view/frontend/templates/footer.phtml +++ b/view/frontend/templates/footer.phtml @@ -1,9 +1,19 @@ getConfig(); -$pageType = $block->getPageType(); +use BasicRum\Analytics\ViewModel\Footer; +use Magento\Framework\Escaper; +use Magento\Framework\View\Element\Template; +use Magento\Framework\View\Helper\SecureHtmlRenderer; + +/** @var Template $block */ +/** @var Footer $viewModel */ +/** @var SecureHtmlRenderer $secureRenderer */ +/** @var Escaper $escaper */ + +$viewModel = $block->getViewModel(); +$config = $viewModel->getConfig(); +$pageType = $viewModel->getPageType(); $scriptString = <<