Skip to content

Commit

Permalink
Fix call to undefined method
Browse files Browse the repository at this point in the history
  • Loading branch information
fredden committed Jul 4, 2023
1 parent 730510e commit 4572822
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Controller/Adminhtml/Config/Job/MassScheduleNow.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace EthanYehuda\CronjobManager\Controller\Adminhtml\Config\Job;

use EthanYehuda\CronjobManager\Model\ManagerFactory;
use Magento\Framework\View\Result\PageFactory;
use EthanYehuda\CronjobManager\Model\ScheduleManagement;
use Magento\Backend\App\Action\Context;
use Magento\Backend\App\Action;

Expand All @@ -13,11 +12,11 @@ class MassScheduleNow extends Action

/**
* @param Context $context
* @param ManagerFactory $managerFactory
* @param ScheduleManagement $scheduleManagement
*/
public function __construct(
Context $context,
private readonly ManagerFactory $managerFactory,
private readonly ScheduleManagement $scheduleManagement,
) {
parent::__construct($context);
}
Expand All @@ -29,17 +28,16 @@ public function __construct(
*/
public function execute()
{
$manager = $this->managerFactory->create();
$params = $this->getRequest()->getParam('selected');
if (!isset($params)) {
$this->getMessageManager()->addErrorMessage("Something went wrong when recieving the request");
$this->getMessageManager()->addErrorMessage("Something went wrong when receiving the request");
$this->_redirect('*/config/index');
return;
}

try {
foreach ($params as $jobCode) {
$manager->scheduleNow($jobCode);
$this->scheduleManagement->scheduleNow($jobCode);
}
} catch (\Exception $e) {
$this->getMessageManager()->addErrorMessage($e->getMessage());
Expand Down

0 comments on commit 4572822

Please sign in to comment.