Refactor SimpleWorker::proccessTaskStrategy() to use Doctrine

Replaces all instances of ScheduledTask with ScheduledTaskEntity

[MAILPOET-3843]
This commit is contained in:
Rodrigo Primo
2021-09-30 11:38:22 -03:00
committed by Veljko V
parent 6ae1e0b400
commit 58f29a0f42
3 changed files with 8 additions and 6 deletions

View File

@@ -3,7 +3,6 @@
namespace MailPoet\Cron; namespace MailPoet\Cron;
use MailPoet\Entities\ScheduledTaskEntity; use MailPoet\Entities\ScheduledTaskEntity;
use MailPoet\Models\ScheduledTask;
interface CronWorkerInterface { interface CronWorkerInterface {
/** @return string */ /** @return string */
@@ -28,11 +27,11 @@ interface CronWorkerInterface {
public function prepareTaskStrategy(ScheduledTaskEntity $task, $timer); public function prepareTaskStrategy(ScheduledTaskEntity $task, $timer);
/** /**
* @param ScheduledTask $task * @param ScheduledTaskEntity $task
* @param float $timer * @param float $timer
* @return bool * @return bool
*/ */
public function processTaskStrategy(ScheduledTask $task, $timer); public function processTaskStrategy(ScheduledTaskEntity $task, $timer);
/** @return \DateTimeInterface */ /** @return \DateTimeInterface */
public function getNextRunDate(); public function getNextRunDate();

View File

@@ -127,7 +127,11 @@ class CronWorkerRunner {
$this->startProgress($task); $this->startProgress($task);
try { try {
$completed = $worker->processTaskStrategy($task, $this->timer); $completed = false;
$doctrineTask = $this->convertTaskClassToDoctrine($task);
if ($doctrineTask) {
$completed = $worker->processTaskStrategy($doctrineTask, $this->timer);
}
} catch (\Exception $e) { } catch (\Exception $e) {
$this->stopProgress($task); $this->stopProgress($task);
throw $e; throw $e;

View File

@@ -8,7 +8,6 @@ use MailPoet\Cron\CronWorkerRunner;
use MailPoet\Cron\CronWorkerScheduler; use MailPoet\Cron\CronWorkerScheduler;
use MailPoet\DI\ContainerWrapper; use MailPoet\DI\ContainerWrapper;
use MailPoet\Entities\ScheduledTaskEntity; use MailPoet\Entities\ScheduledTaskEntity;
use MailPoet\Models\ScheduledTask;
use MailPoet\Newsletter\Sending\ScheduledTasksRepository; use MailPoet\Newsletter\Sending\ScheduledTasksRepository;
use MailPoet\WP\Functions as WPFunctions; use MailPoet\WP\Functions as WPFunctions;
use MailPoetVendor\Carbon\Carbon; use MailPoetVendor\Carbon\Carbon;
@@ -73,7 +72,7 @@ abstract class SimpleWorker implements CronWorkerInterface {
return true; return true;
} }
public function processTaskStrategy(ScheduledTask $task, $timer) { public function processTaskStrategy(ScheduledTaskEntity $task, $timer) {
return true; return true;
} }