Delete   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A execute() 0 8 1
1
<?php
2
declare(strict_types=1);
3
/**
4
 * File: Delete.php
5
 * @package     LizardMedia
6
 * @category    CronScheduler
7
 * @author:     Krzysztof Kuźniar <[email protected]>
8
 * @copyright   Copyright (C) 2018 LizardMedia (http://www.lizardmedia.pl)
9
 */
10
namespace LizardMedia\CronScheduler\Controller\Adminhtml\Manage\MassActions;
11
12
use Exception;
13
use Magento\Backend\App\Action;
14
use Magento\Backend\App\Action\Context;
15
use LizardMedia\CronScheduler\Model\Manage\MassActions\Delete as MassActionDelete;
16
use Magento\Framework\App\ResponseInterface;
17
use Magento\Framework\Controller\ResultInterface;
18
19
/**
20
 * Class Delete
21
 * @package LizardMedia\CronScheduler\Controller\Adminhtml\Manage\MassActions
22
 */
23
class Delete extends Action
24
{
25
    /**
26
     * @const string
27
     */
28
    const DELETE_MESSAGE = 'Successfully Deleted Job Item';
29
30
    /**
31
     * @var MassActionDelete
32
     */
33
    private $deleteAction;
34
35
    /**
36
     * Delete constructor.
37
     * @param MassActionDelete $deleteAction
38
     * @param Context $context
39
     */
40
    public function __construct(
41
        MassActionDelete $deleteAction,
42
        Context $context
43
    ) {
44
    
45
        $this->deleteAction = $deleteAction;
46
        parent::__construct($context);
47
    }
48
49
    /**
50
     * @return ResponseInterface|ResultInterface|void
51
     * @throws Exception
52
     */
53
    public function execute()
54
    {
55
        $jobsIds = $this->getRequest()->getParam('selected');
56
        $this->deleteAction->deleteJobs($jobsIds);
57
58
        $this->getMessageManager()->addSuccessMessage(self::DELETE_MESSAGE);
59
        $this->_redirect("cron/scheduler/index/");
60
    }
61
}
62