-
Notifications
You must be signed in to change notification settings - Fork 138
Expand file tree
/
Copy pathQueuePlugin.php
More file actions
78 lines (67 loc) · 1.97 KB
/
Copy pathQueuePlugin.php
File metadata and controls
78 lines (67 loc) · 1.97 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
declare(strict_types=1);
namespace Queue;
use Cake\Console\CommandCollection;
use Cake\Core\BasePlugin;
use Cake\Core\ContainerInterface;
use Cake\Routing\RouteBuilder;
use Queue\Command\AddCommand;
use Queue\Command\BakeQueueTaskCommand;
use Queue\Command\InfoCommand;
use Queue\Command\JobCommand;
use Queue\Command\RunCommand;
use Queue\Command\WorkerCommand;
/**
* Plugin for Queue
*/
class QueuePlugin extends BasePlugin {
/**
* @var bool
*/
protected bool $middlewareEnabled = false;
/**
* Console hook
*
* @param \Cake\Console\CommandCollection $commands The command collection
*
* @return \Cake\Console\CommandCollection
*/
public function console(CommandCollection $commands): CommandCollection {
$commands->add('queue add', AddCommand::class);
$commands->add('queue info', InfoCommand::class);
$commands->add('queue run', RunCommand::class);
$commands->add('queue worker', WorkerCommand::class);
$commands->add('queue job', JobCommand::class);
if (class_exists('Bake\Command\SimpleBakeCommand')) {
$commands->add('bake queue_task', BakeQueueTaskCommand::class);
}
return $commands;
}
/**
* @param \Cake\Routing\RouteBuilder $routes The route builder to update.
*
* @return void
*/
public function routes(RouteBuilder $routes): void {
$routes->prefix('Admin', function (RouteBuilder $routes): void {
$routes->plugin('Queue', function (RouteBuilder $routes): void {
$routes->connect('/', ['controller' => 'Queue', 'action' => 'index']);
$routes->fallbacks();
});
});
$routes->plugin('Queue', ['path' => '/queue'], function (RouteBuilder $routes): void {
$routes->connect('/{controller}');
});
}
/**
* @param \Cake\Core\ContainerInterface $container The DI container instance
*
* @return void
*/
public function services(ContainerInterface $container): void {
$container->add(ContainerInterface::class, $container);
$container
->add(RunCommand::class)
->addArgument(ContainerInterface::class);
}
}