<?php

declare(strict_types=1);

namespace Autogedal\PayPo\Block\Product;

use Magento\Catalog\Model\Product;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Registry;
use Magento\Framework\View\Element\Template;
use Magento\Store\Model\ScopeInterface;
use PayPo\Payment\Model\Payment\PayPo;

class PayPoBanner extends Template
{
    public function __construct(
        Template\Context $context,
        private readonly ScopeConfigInterface $scopeConfig,
        private readonly Registry $registry,
        array $data = []
    ) {
        parent::__construct($context, $data);
    }

    public function isPayPoActive(): bool
    {
        return $this->scopeConfig->isSetFlag(
            'payment/' . PayPo::METHOD_CODE . '/active',
            ScopeInterface::SCOPE_STORE
        );
    }

    public function getProduct(): ?Product
    {
        return $this->registry->registry('current_product');
    }
}
