init
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\MultiLocaleTranslation\Controller\Adminhtml\Log;
|
||||
|
||||
use Esun\MultiLocaleTranslation\Model\LogCleaner;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\App\Action\HttpPostActionInterface;
|
||||
use Magento\Framework\Controller\Result\Redirect;
|
||||
|
||||
class ClearAll extends Action implements HttpPostActionInterface
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_MultiLocaleTranslation::translation_log_delete';
|
||||
|
||||
public function __construct(
|
||||
Action\Context $context,
|
||||
private readonly LogCleaner $logCleaner
|
||||
) {
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute(): Redirect
|
||||
{
|
||||
try {
|
||||
$deleted = $this->logCleaner->clearAll();
|
||||
$this->messageManager->addSuccessMessage(
|
||||
__('%1 Translation API Log record(s) cleared.', $deleted)
|
||||
);
|
||||
} catch (\Throwable $exception) {
|
||||
$this->messageManager->addErrorMessage($exception->getMessage());
|
||||
}
|
||||
|
||||
return $this->resultRedirectFactory->create()->setPath('*/*/index');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user