init
This commit is contained in:
@@ -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('*/*/');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user