Files
2026-09-15 10:35:56 +08:00

42 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace Esun\CustomerVat\Controller\Vat;
use Esun\CustomerVat\Model\VatApplicationService;
use Magento\Customer\Model\Session;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\Registry;
use Magento\Framework\View\Result\PageFactory;
class Edit extends AbstractVat implements HttpGetActionInterface
{
public function __construct(
Context $context,
Session $customerSession,
private readonly PageFactory $pageFactory,
private readonly VatApplicationService $applications,
private readonly Registry $registry
) {
parent::__construct($context, $customerSession);
}
public function execute()
{
try {
$application = $this->applications->getByIdForCustomer(
(int)$this->getRequest()->getParam('id'),
(int)$this->customerSession->getCustomerId()
);
$this->registry->register('current_customer_vat', $application);
$page = $this->pageFactory->create();
$page->getConfig()->getTitle()->set(__('Edit VAT Number'));
return $page;
} catch (\Throwable $exception) {
$this->messageManager->addErrorMessage($exception->getMessage());
return $this->resultRedirectFactory->create()->setPath('*/*/index');
}
}
}