init
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\MultiLocaleTranslation\Block\Adminhtml\Queue;
|
||||
|
||||
use Magento\Backend\Block\Widget\Context;
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
class ClearAllButton implements ButtonProviderInterface
|
||||
{
|
||||
public function __construct(private readonly Context $context)
|
||||
{
|
||||
}
|
||||
|
||||
public function getButtonData(): array
|
||||
{
|
||||
$message = __(
|
||||
'Clear all translation queue records? Pending jobs will be removed. A job already being processed may still finish and write its translation.'
|
||||
);
|
||||
$url = $this->context->getUrlBuilder()->getUrl('localetranslate/queue/clearAll');
|
||||
|
||||
return [
|
||||
'label' => __('Clear All Queue'),
|
||||
'class' => 'delete',
|
||||
'on_click' => 'deleteConfirm('
|
||||
. json_encode((string)$message, JSON_HEX_APOS | JSON_HEX_QUOT)
|
||||
. ', '
|
||||
. json_encode($url, JSON_HEX_APOS | JSON_HEX_QUOT)
|
||||
. ', {"data": {}})',
|
||||
'sort_order' => 10,
|
||||
'aclResource' => 'Esun_MultiLocaleTranslation::queue_delete',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\MultiLocaleTranslation\Block\Adminhtml\Queue;
|
||||
|
||||
use Esun\MultiLocaleTranslation\Model\ProviderConfig;
|
||||
use Esun\MultiLocaleTranslation\Model\Queue\SelectionRegistry;
|
||||
use Esun\MultiLocaleTranslation\Model\StoreViewProvider;
|
||||
use Magento\Backend\Block\Template;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Framework\Data\Form\FormKey;
|
||||
|
||||
class Form extends Template
|
||||
{
|
||||
public function __construct(
|
||||
Context $context,
|
||||
private readonly StoreViewProvider $storeViewProvider,
|
||||
private readonly ProviderConfig $providerConfig,
|
||||
private readonly SelectionRegistry $selectionRegistry,
|
||||
private readonly FormKey $formKeyService,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
public function getSelection(): ?array
|
||||
{
|
||||
return $this->selectionRegistry->get($this->getToken());
|
||||
}
|
||||
|
||||
public function getToken(): string
|
||||
{
|
||||
return (string)$this->getRequest()->getParam('token');
|
||||
}
|
||||
|
||||
public function getStoreGroups(): array
|
||||
{
|
||||
return $this->storeViewProvider->getStoreViewGroups();
|
||||
}
|
||||
|
||||
public function getProviders(): array
|
||||
{
|
||||
return $this->providerConfig->getEnabledOptions();
|
||||
}
|
||||
|
||||
public function getDefaultProvider(): string
|
||||
{
|
||||
return $this->providerConfig->getDefaultProvider();
|
||||
}
|
||||
|
||||
public function getSubmitUrl(): string
|
||||
{
|
||||
return $this->getUrl('localetranslate/queue/add');
|
||||
}
|
||||
|
||||
public function getQueueUrl(): string
|
||||
{
|
||||
return $this->getUrl('localetranslate/queue/index');
|
||||
}
|
||||
|
||||
public function getFormKeyValue(): string
|
||||
{
|
||||
return $this->formKeyService->getFormKey();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user