-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.php
More file actions
53 lines (44 loc) · 1.32 KB
/
start.php
File metadata and controls
53 lines (44 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
Autoloader::namespaces(array(
'TaskQueue' => __DIR__ . DS . 'TaskQueue'
));
Autoloader::alias('TaskQueue\\Queues', 'Queues');
/*
|--------------------------------------------------------------------------
| Register Queues to the IoC container
|--------------------------------------------------------------------------
|
| Register Queues to the IoC container for easy access and use. We
| register it as a singleton since there is no need to have multiple
| instances at the same time.
|
*/
IoC::singleton('Queues', function()
{
$repository = new TaskQueue\Repositories\FluentQueueRepository;
return new TaskQueue\Queues($repository);
});
/*
|--------------------------------------------------------------------------
| Add the routes
|--------------------------------------------------------------------------
|
| Adds the routes that handle the queues. Easily accessible so it can be
| run asynchronous and so it doesn't depend on being accessed by artisan.
|
*/
Route::get(Bundle::get('task-queue.handles'), function()
{
$queues = IoC::resolve('Queues');
$queues->runAll(true);
});
Route::get(Bundle::get('task-queue.handles') . '/(:num)', function($id)
{
$queues = IoC::resolve('Queues');
$queue = $queues->get($id);
if( ! is_null($queue))
{
$queues->run($queue);
Log::write('queues', 'run ' . $queue->id);
}
});