Skip to content

Commit e17696a

Browse files
author
Aleksey Kulagin
committed
fix yii2 version
1 parent 457e697 commit e17696a

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"require": {
1414
"php": "^7.0",
15-
"yiisoft/yii2": "^2.0",
15+
"yiisoft/yii2": "^2.0.13",
1616
"php-amqplib/php-amqplib": "^2.9"
1717
},
1818
"require-dev": {

controllers/RabbitMQController.php

+20-19
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use ReflectionException;
1111
use yii\base\Action;
1212
use yii\console\Controller;
13+
use yii\console\ExitCode;
1314
use yii\helpers\Console;
1415

1516
/**
@@ -101,7 +102,7 @@ public function actionConsume(string $name): int
101102
{
102103
$this->stderr(Console::ansiFormat("Consumer `{$name}` doesn't exist: {$e->getMessage()}\n", [Console::FG_RED]));
103104

104-
return self::EXIT_CODE_ERROR;
105+
return ExitCode::UNSPECIFIED_ERROR;
105106
}
106107

107108
$this->validateConsumerOptions($consumer);
@@ -111,7 +112,7 @@ public function actionConsume(string $name): int
111112
}
112113
$consumer->consume($this->messagesLimit);
113114

114-
return self::EXIT_CODE_NORMAL;
115+
return ExitCode::OK;
115116
}
116117

117118
/**
@@ -136,15 +137,15 @@ public function actionPublish(string $producerName, string $exchangeName, string
136137
{
137138
$this->stderr(Console::ansiFormat("Producer `{$producerName}` doesn't exist: {$e->getMessage()}\n", [Console::FG_RED]));
138139

139-
return self::EXIT_CODE_ERROR;
140+
return ExitCode::UNSPECIFIED_ERROR;
140141
}
141142

142143
$data = '';
143144
if (posix_isatty(STDIN))
144145
{
145146
$this->stderr(Console::ansiFormat("Please pipe in some data in order to send it.\n", [Console::FG_RED]));
146147

147-
return self::EXIT_CODE_ERROR;
148+
return ExitCode::UNSPECIFIED_ERROR;
148149
}
149150
while (!feof(STDIN))
150151
{
@@ -153,7 +154,7 @@ public function actionPublish(string $producerName, string $exchangeName, string
153154
$producer->publish($data, $exchangeName, $routingKey);
154155
$this->stdout("Message was successfully published.\n", Console::FG_GREEN);
155156

156-
return self::EXIT_CODE_NORMAL;
157+
return ExitCode::OK;
157158
}
158159

159160
/**
@@ -175,11 +176,11 @@ public function actionDeclareAll(string $connectionName = Configuration::DEFAULT
175176
Console::ansiFormat("All configured entries was successfully declared.\n", [Console::FG_GREEN])
176177
);
177178

178-
return self::EXIT_CODE_NORMAL;
179+
return ExitCode::OK;
179180
}
180181
$this->stderr(Console::ansiFormat("No queues, exchanges or bindings configured.\n", [Console::FG_RED]));
181182

182-
return self::EXIT_CODE_ERROR;
183+
return ExitCode::UNSPECIFIED_ERROR;
183184
}
184185

185186
/**
@@ -201,12 +202,12 @@ public function actionDeclareExchange(
201202
{
202203
$this->stderr(Console::ansiFormat("Exchange `{$exchangeName}` is already exists.\n", [Console::FG_RED]));
203204

204-
return self::EXIT_CODE_ERROR;
205+
return ExitCode::UNSPECIFIED_ERROR;
205206
}
206207
$routing->declareExchange($exchangeName);
207208
$this->stdout(Console::ansiFormat("Exchange `{$exchangeName}` was declared.\n", [Console::FG_GREEN]));
208209

209-
return self::EXIT_CODE_NORMAL;
210+
return ExitCode::OK;
210211
}
211212

212213
/**
@@ -228,12 +229,12 @@ public function actionDeclareQueue(
228229
{
229230
$this->stderr(Console::ansiFormat("Queue `{$queueName}` is already exists.\n", [Console::FG_RED]));
230231

231-
return self::EXIT_CODE_ERROR;
232+
return ExitCode::UNSPECIFIED_ERROR;
232233
}
233234
$routing->declareQueue($queueName);
234235
$this->stdout(Console::ansiFormat("Queue `{$queueName}` was declared.\n", [Console::FG_GREEN]));
235236

236-
return self::EXIT_CODE_NORMAL;
237+
return ExitCode::OK;
237238
}
238239

239240
/**
@@ -253,15 +254,15 @@ public function actionDeleteAll(string $connection = Configuration::DEFAULT_CONN
253254
{
254255
$this->stderr(Console::ansiFormat("Aborted.\n", [Console::FG_RED]));
255256

256-
return self::EXIT_CODE_ERROR;
257+
return ExitCode::UNSPECIFIED_ERROR;
257258
}
258259
}
259260
$conn = \Yii::$app->rabbitmq->getConnection($connection);
260261
$routing = \Yii::$app->rabbitmq->getRouting($conn);
261262
$routing->deleteAll();
262263
$this->stdout(Console::ansiFormat("All configured entries was deleted.\n", [Console::FG_GREEN]));
263264

264-
return self::EXIT_CODE_NORMAL;
265+
return ExitCode::OK;
265266
}
266267

267268
/**
@@ -284,15 +285,15 @@ public function actionDeleteExchange(
284285
{
285286
$this->stderr(Console::ansiFormat("Aborted.\n", [Console::FG_RED]));
286287

287-
return self::EXIT_CODE_ERROR;
288+
return ExitCode::UNSPECIFIED_ERROR;
288289
}
289290
}
290291
$conn = \Yii::$app->rabbitmq->getConnection($connectionName);
291292
$routing = \Yii::$app->rabbitmq->getRouting($conn);
292293
$routing->deleteExchange($exchangeName);
293294
$this->stdout(Console::ansiFormat("Exchange `{$exchangeName}` was deleted.\n", [Console::FG_GREEN]));
294295

295-
return self::EXIT_CODE_NORMAL;
296+
return ExitCode::OK;
296297
}
297298

298299
/**
@@ -315,7 +316,7 @@ public function actionDeleteQueue(
315316
{
316317
$this->stderr(Console::ansiFormat("Aborted.\n", [Console::FG_RED]));
317318

318-
return self::EXIT_CODE_ERROR;
319+
return ExitCode::UNSPECIFIED_ERROR;
319320
}
320321
}
321322

@@ -324,7 +325,7 @@ public function actionDeleteQueue(
324325
$routing->deleteQueue($queueName);
325326
$this->stdout(Console::ansiFormat("Queue `{$queueName}` was deleted.\n", [Console::FG_GREEN]));
326327

327-
return self::EXIT_CODE_NORMAL;
328+
return ExitCode::OK;
328329
}
329330

330331
/**
@@ -350,7 +351,7 @@ public function actionPurgeQueue(
350351
{
351352
$this->stderr(Console::ansiFormat("Aborted.\n", [Console::FG_RED]));
352353

353-
return self::EXIT_CODE_ERROR;
354+
return ExitCode::UNSPECIFIED_ERROR;
354355
}
355356
}
356357

@@ -359,7 +360,7 @@ public function actionPurgeQueue(
359360
$routing->purgeQueue($queueName);
360361
$this->stdout(Console::ansiFormat("Queue `{$queueName}` was purged.\n", [Console::FG_GREEN]));
361362

362-
return self::EXIT_CODE_NORMAL;
363+
return ExitCode::OK;
363364
}
364365

365366
/**

events/RabbitMQConsumerEvent.php

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace mikemadisonweb\rabbitmq\events;
44

5+
use mikemadisonweb\rabbitmq\components\Consumer;
6+
use PhpAmqpLib\Message\AMQPMessage;
57
use yii\base\Event;
68

79
class RabbitMQConsumerEvent extends Event

events/RabbitMQPublisherEvent.php

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace mikemadisonweb\rabbitmq\events;
44

5+
use mikemadisonweb\rabbitmq\components\Consumer;
6+
use PhpAmqpLib\Message\AMQPMessage;
57
use yii\base\Event;
68

79
class RabbitMQPublisherEvent extends Event

0 commit comments

Comments
 (0)