1
|
|
|
<?php |
2
|
|
|
namespace NeedleProject\LaravelRabbitMq\Command; |
3
|
|
|
|
4
|
|
|
use Illuminate\Console\Command; |
5
|
|
|
use Monolog\Handler\StreamHandler; |
6
|
|
|
use Monolog\Logger; |
7
|
|
|
use NeedleProject\LaravelRabbitMq\ConsumerInterface; |
8
|
|
|
use NeedleProject\LaravelRabbitMq\Container; |
9
|
|
|
use NeedleProject\LaravelRabbitMq\PublisherInterface; |
10
|
|
|
use Psr\Log\LoggerAwareInterface; |
11
|
|
|
use Psr\Log\LoggerInterface; |
12
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class BasePublisherCommand |
16
|
|
|
* |
17
|
|
|
* @package NeedleProject\LaravelRabbitMq\Command |
18
|
|
|
* @author Adrian Tilita <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class BasePublisherCommand extends Command |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* The name and signature of the console command. |
24
|
|
|
* |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
protected $signature = 'rabbitmq:publish {publisher} {message}'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* The console command description. |
31
|
|
|
* |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $description = 'Publish one message'; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var null|Container |
38
|
|
|
*/ |
39
|
|
|
private $container = null; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* BasePublisherCommand constructor. |
43
|
|
|
* |
44
|
|
|
* @param Container $container |
45
|
|
|
*/ |
46
|
1 |
|
public function __construct(Container $container) |
47
|
|
|
{ |
48
|
1 |
|
$this->container = $container; |
49
|
1 |
|
parent::__construct(); |
50
|
1 |
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param string $publisherAliasName |
54
|
|
|
* @return PublisherInterface |
55
|
|
|
*/ |
56
|
1 |
|
protected function getPublisher(string $publisherAliasName): PublisherInterface |
57
|
|
|
{ |
58
|
1 |
|
return $this->container->getPublisher($publisherAliasName); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Execute the console command. |
63
|
|
|
* @return int |
64
|
|
|
*/ |
65
|
1 |
|
public function handle() |
66
|
|
|
{ |
67
|
1 |
|
$this->getPublisher($this->input->getArgument('publisher')) |
68
|
1 |
|
->publish($this->input->getArgument('message')); |
69
|
1 |
|
return 0; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.