Skip to content

Commit 5353442

Browse files
author
Ryan McCaw
committed
Load the Plugin correctly and changed references to queue_ to queue
because file names are now Camel case
1 parent 10b603b commit 5353442

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

Console/Command/QueueShell.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function initialize() {
3737

3838
foreach (App::path('shells') as $path) {
3939
$folder = new Folder($path . DS . 'Task');
40-
$this->tasks = array_merge($this->tasks, $folder->find('Queue.*\.php'));
40+
$this->tasks = array_merge($this->tasks, $folder->find('queue.*\.php'));
4141
}
4242
// strip the extension fom the found task(file)s
4343
foreach ($this->tasks as &$task) {
@@ -110,8 +110,8 @@ public function add() {
110110
} else {
111111
if (in_array($this->args[0], $this->taskNames)) {
112112
$this->{$this->args[0]}->add();
113-
} elseif (in_array('queue_' . $this->args[0], $this->taskNames)) {
114-
$this->{'queue_' . $this->args[0]}->add();
113+
} elseif (in_array('queue' . $this->args[0], $this->taskNames)) {
114+
$this->{'queue' . $this->args[0]}->add();
115115
} else {
116116
$this->out('Error:');
117117
$this->out(' Task not found: ' . $this->args[0], 2);
@@ -152,7 +152,7 @@ public function runworker() {
152152
} else {
153153
if ($data !== false) {
154154
$this->out('Running Job of type "' . $data['jobtype'] . '"');
155-
$taskname = 'queue_' . strtolower($data['jobtype']);
155+
$taskname = 'queue' . $data['jobtype'];
156156
$jobData = unserialize($data['data']);
157157
if (!$this->{$taskname}->canRun($jobData)) {
158158
$this->QueuedTask->requeueJob($data['id'], $this->getTaskConf($taskname, 'timeout'));

Console/Command/Task/QueueExampleTask.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class queueExampleTask extends Shell {
1919
* @var array
2020
*/
2121
public $uses = array(
22-
'Queue.QueuedTask'
22+
'CakephpQueue.QueuedTask'
2323
);
2424

2525
/**

Console/Command/Task/QueueExecuteTask.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class queueExecuteTask extends Shell {
1919
* @var array
2020
*/
2121
public $uses = array(
22-
'Queue.QueuedTask'
22+
'CakephpQueue.QueuedTask'
2323
);
2424

2525
/**

Model/QueuedTask.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function requestJob($capabilities, $group = null) {
114114
// generate the task specific conditions.
115115
foreach ($capabilities as $task) {
116116
$tmp = array(
117-
'jobtype' => str_replace('queue_', '', $task['name']),
117+
'jobtype' => str_replace('queue', '', $task['name']),
118118
'AND' => array(
119119
array(
120120
'OR' => array(
@@ -138,6 +138,7 @@ public function requestJob($capabilities, $group = null) {
138138
}
139139
// First, find a list of a few of the oldest unfinished tasks.
140140
$data = $this->find('all', $findConf);
141+
141142
if (is_array($data) && count($data) > 0) {
142143
// generate a list of their ID's
143144
foreach ($data as $item) {

Model/QueuedTaskResponse.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
77
In some controller:
88
9-
var $uses = array('Queue.QueuedTask', 'Queue.QueuedTaskResponse');
9+
var $uses = array('CakephpQueue.QueuedTask', 'CakephpQueue.QueuedTaskResponse');
1010
1111
function action() {
1212
$key = $this->QueuedTaskResponse->generate();
13-
$this->QueuedTask->createJob('some_task', array('response_key' => $key));
13+
$this->QueuedTask->createJob('SomeTask', array('response_key' => $key));
1414
$response = $this->QueuedTaskResponse->getValue($key, true);
1515
$this->set('response', $response);
1616
}
1717
1818
In your queue task:
1919
20-
var $uses = array('Queue.QueuedTaskResponse');
20+
var $uses = array('CakephpQueue.QueuedTaskResponse');
2121
function run($data) {
2222
$this->QueuedTaskResponse->setValue($data['response_key'], 'Return value');
2323
}

Test/cases/models/queued_task.test.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @link http://github.com/MSeven/cakephp_queue
88
*/
99

10-
App::import('Model', 'Queue.QueuedTask');
10+
App::import('Model', 'CakephpQueue.QueuedTask');
1111

1212
class TestQueuedTask extends QueuedTask {
1313
public $name = 'TestQueuedTask';

0 commit comments

Comments
 (0)