41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Esun\CustomerVat\Block\Adminhtml\Application;
|
|
|
|
use Esun\CustomerVat\Model\EuCountries;
|
|
use Esun\CustomerVat\Model\VatApplication;
|
|
use Magento\Backend\Block\Template;
|
|
use Magento\Customer\Api\CustomerRepositoryInterface;
|
|
use Magento\Framework\Registry;
|
|
|
|
class View extends Template
|
|
{
|
|
public function __construct(Template\Context $context, private readonly Registry $registry,
|
|
private readonly CustomerRepositoryInterface $customers, private readonly EuCountries $countries,
|
|
array $data = [])
|
|
{
|
|
parent::__construct($context, $data);
|
|
}
|
|
|
|
public function getApplication(): VatApplication
|
|
{
|
|
return $this->registry->registry('current_customer_vat_admin');
|
|
}
|
|
|
|
public function getCustomer()
|
|
{
|
|
return $this->customers->getById((int)$this->getApplication()->getData('customer_id'));
|
|
}
|
|
|
|
public function getCountryName(string $id): string
|
|
{
|
|
foreach ($this->countries->getOptions() as $option) {
|
|
if ($option['value'] === $id) {
|
|
return (string)$option['label'];
|
|
}
|
|
}
|
|
return $id;
|
|
}
|
|
}
|