This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Controller\Adminhtml\Application;
use Esun\Agent\Model\ApplicationFactory;
use Magento\Backend\App\Action;
use Magento\Framework\Controller\Result\Redirect;
class Delete extends Action
{
public const ADMIN_RESOURCE = 'Esun_Agent::applications_delete';
public function __construct(Action\Context $context, private readonly ApplicationFactory $applicationFactory)
{
parent::__construct($context);
}
public function execute(): Redirect
{
try {
$application = $this->applicationFactory->create()->load((int)$this->getRequest()->getParam('entity_id'));
if (!$application->getId()) {
throw new \RuntimeException('Application not found.');
}
$application->delete();
$this->messageManager->addSuccessMessage(__('The application has been deleted.'));
} catch (\Throwable $exception) {
$this->messageManager->addErrorMessage(__('The application could not be deleted.'));
}
return $this->resultRedirectFactory->create()->setPath('*/*/');
}
}
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Controller\Adminhtml\Application;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\Page;
use Magento\Framework\View\Result\PageFactory;
class Index extends Action
{
public const ADMIN_RESOURCE = 'Esun_Agent::applications';
public function __construct(Context $context, private readonly PageFactory $pageFactory)
{
parent::__construct($context);
}
public function execute(): Page
{
$page = $this->pageFactory->create();
$page->setActiveMenu('Esun_Agent::applications');
$page->getConfig()->getTitle()->prepend(__('Agent Applications'));
return $page;
}
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Controller\Adminhtml\Application;
use Esun\Agent\Model\ResourceModel\Application\CollectionFactory;
use Magento\Backend\App\Action;
use Magento\Framework\Controller\Result\Redirect;
use Magento\Ui\Component\MassAction\Filter;
class MassDelete extends Action
{
public const ADMIN_RESOURCE = 'Esun_Agent::applications_delete';
public function __construct(
Action\Context $context,
private readonly Filter $filter,
private readonly CollectionFactory $collectionFactory
) {
parent::__construct($context);
}
public function execute(): Redirect
{
$collection = $this->filter->getCollection($this->collectionFactory->create());
$deleted = 0;
foreach ($collection as $application) {
$application->delete();
$deleted++;
}
$this->messageManager->addSuccessMessage(
__('A total of %1 application(s) have been deleted.', $deleted)
);
return $this->resultRedirectFactory->create()->setPath('*/*/');
}
}