45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Esun\Translation\Controller\Adminhtml\Translate;
|
|
|
|
use Magento\Backend\App\Action;
|
|
use Magento\Backend\App\Action\Context;
|
|
use Magento\Framework\Controller\ResultInterface;
|
|
use Magento\Framework\View\Result\PageFactory;
|
|
|
|
class Index extends Action
|
|
{
|
|
public const ADMIN_RESOURCE = 'Magento_Backend::admin';
|
|
|
|
public function __construct(
|
|
Context $context,
|
|
private readonly PageFactory $pageFactory
|
|
) {
|
|
parent::__construct($context);
|
|
}
|
|
|
|
public function execute(): ResultInterface
|
|
{
|
|
$page = $this->pageFactory->create();
|
|
$page->getConfig()->getTitle()->prepend(__('Esun Translation'));
|
|
|
|
return $page;
|
|
}
|
|
|
|
protected function _isAllowed(): bool
|
|
{
|
|
return $this->_authorization->isAllowed($this->getTranslateResource());
|
|
}
|
|
|
|
private function getTranslateResource(): string
|
|
{
|
|
return match ((string)$this->getRequest()->getParam('entity_type', 'product')) {
|
|
'cms_page' => 'Esun_Translation::translate_cms_page',
|
|
'cms_block' => 'Esun_Translation::translate_cms_block',
|
|
default => 'Esun_Translation::translate_product',
|
|
};
|
|
}
|
|
}
|