-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from uafrica/cake36
Cake 3.6 upgrade
- Loading branch information
Showing
23 changed files
with
451 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace DelayedJobs\DelayedJob; | ||
|
||
use DelayedJobs\Broker\BrokerInterface; | ||
use DelayedJobs\Datasource\DatasourceInterface; | ||
|
||
/** | ||
* Class DebugKitJobManager | ||
*/ | ||
class DebugKitJobManager extends JobManager | ||
{ | ||
/** | ||
* A reference to the object were jobs will be pushed too for logging | ||
* | ||
* @var \ArrayObject | ||
*/ | ||
protected $jobLog; | ||
|
||
public function __construct( | ||
array $config = [], | ||
\DelayedJobs\Datasource\DatasourceInterface $datastore = null, | ||
\DelayedJobs\Broker\BrokerInterface $messageBroker = null | ||
) { | ||
$this->jobLog = $config['debugKitLog']; | ||
unset($config['debugKitLog']); | ||
|
||
parent::__construct($config, $datastore, $messageBroker); | ||
} | ||
|
||
/** | ||
* @param \DelayedJobs\DelayedJob\Job $job The job instance | ||
* @return void | ||
*/ | ||
protected function pushToLog(Job $job) | ||
{ | ||
$jobData = [ | ||
'id' => $job->getId(), | ||
'worker' => $job->getWorker(), | ||
'sequence' => $job->getSequence(), | ||
'payload' => $job->getPayload(), | ||
'priority' => $job->getPriority(), | ||
'pushedToBroker' => $job->isPushedToBroker(), | ||
]; | ||
$this->jobLog[] = $jobData; | ||
} | ||
|
||
/** | ||
* @param \DelayedJobs\DelayedJob\Job $job Job that needs to be enqueued | ||
* @param bool $skipPersist Skip the persistance step (e.g. it's already been persisted | ||
* @return void | ||
*/ | ||
public function enqueue(Job $job, bool $skipPersist = false) | ||
{ | ||
parent::enqueue($job, $skipPersist); | ||
|
||
$this->pushToLog($job); | ||
} | ||
|
||
/** | ||
* @param array $jobs | ||
* @return void | ||
*/ | ||
public function enqueueBatch(array $jobs) | ||
{ | ||
parent::enqueueBatch($jobs); | ||
|
||
foreach ($jobs as $job) { | ||
$this->pushToLog($job); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace DelayedJobs\Generator\Task; | ||
|
||
use Cake\Core\App; | ||
use DelayedJobs\DelayedJob\Job; | ||
use DelayedJobs\WorkerFinder; | ||
use IdeHelper\Generator\Task\TaskInterface; | ||
|
||
/** | ||
* Class WorkerTask | ||
*/ | ||
class WorkerTask implements TaskInterface | ||
{ | ||
const CLASS_JOB = Job::class; | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function collect() | ||
{ | ||
$map = []; | ||
$workers = $this->collectWorkers(); | ||
$map = []; | ||
foreach ($workers as $worker) { | ||
$map[$worker] = '\\' . static::CLASS_JOB . '::class'; | ||
} | ||
|
||
$result['\\' . static::CLASS_JOB . '::enqueue(0)'] = $map; | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
protected function collectWorkers() | ||
{ | ||
$result = []; | ||
$workerFinder = new WorkerFinder(); | ||
$workers = $workerFinder->allAppAndPluginWorkers(); | ||
sort($workers); | ||
|
||
return $workers; | ||
} | ||
} |
Oops, something went wrong.