2
2
3
3
namespace EthanYehuda \CronjobManager \Controller \Adminhtml \Config \Job ;
4
4
5
- use EthanYehuda \CronjobManager \Model \ManagerFactory ;
6
- use Magento \Framework \View \Result \PageFactory ;
5
+ use EthanYehuda \CronjobManager \Model \ScheduleManagement ;
7
6
use Magento \Backend \App \Action \Context ;
8
7
use Magento \Backend \App \Action ;
9
8
@@ -13,11 +12,11 @@ class MassScheduleNow extends Action
13
12
14
13
/**
15
14
* @param Context $context
16
- * @param ManagerFactory $managerFactory
15
+ * @param ScheduleManagement $scheduleManagement
17
16
*/
18
17
public function __construct (
19
18
Context $ context ,
20
- private readonly ManagerFactory $ managerFactory ,
19
+ private readonly ScheduleManagement $ scheduleManagement ,
21
20
) {
22
21
parent ::__construct ($ context );
23
22
}
@@ -29,17 +28,16 @@ public function __construct(
29
28
*/
30
29
public function execute ()
31
30
{
32
- $ manager = $ this ->managerFactory ->create ();
33
31
$ params = $ this ->getRequest ()->getParam ('selected ' );
34
32
if (!isset ($ params )) {
35
- $ this ->getMessageManager ()->addErrorMessage ("Something went wrong when recieving the request " );
33
+ $ this ->getMessageManager ()->addErrorMessage ("Something went wrong when receiving the request " );
36
34
$ this ->_redirect ('*/config/index ' );
37
35
return ;
38
36
}
39
37
40
38
try {
41
39
foreach ($ params as $ jobCode ) {
42
- $ manager ->scheduleNow ($ jobCode );
40
+ $ this -> scheduleManagement ->scheduleNow ($ jobCode );
43
41
}
44
42
} catch (\Exception $ e ) {
45
43
$ this ->getMessageManager ()->addErrorMessage ($ e ->getMessage ());
0 commit comments