Skip to content

Commit

Permalink
Updated to follow zhuravljov/yii2-queue API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed May 4, 2017
1 parent 1aa2d23 commit b07d11b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"hiqdev/yii2-pnotify": "<2.0 || dev-master",
"yiisoft/yii2-debug": "^2.0",
"guzzlehttp/guzzle": "^6.0",
"zhuravljov/yii2-queue": "<2.0 || dev-master"
"zhuravljov/yii2-queue": "^1.0"
},
"require-dev": {
"hiqdev/hidev": "dev-master",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/CollectDependenciesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class CollectDependenciesCommand extends AbstractPackageCommand
{
public function run()
public function execute($queue)
{
$this->beforeRun();

Expand All @@ -45,7 +45,7 @@ public function run()
continue;
}

Yii::$app->queue->push(Yii::createObject(PackageUpdateCommand::class, [$assetPackage]));
$queue->push(Yii::createObject(PackageUpdateCommand::class, [$assetPackage]));
Yii::trace(Console::renderColoredString('Created update command for %Y' . $assetPackage->getFullName() . "%n package\n"), __CLASS__);
}

Expand Down
4 changes: 2 additions & 2 deletions src/commands/PackageUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
class PackageUpdateCommand extends AbstractPackageCommand
{
public function run()
public function execute($queue)
{
$this->beforeRun();

Expand All @@ -40,7 +40,7 @@ public function run()
throw $e;
}

Yii::$app->queue->push(Yii::createObject(CollectDependenciesCommand::class, [$this->package]));
$queue->push(Yii::createObject(CollectDependenciesCommand::class, [$this->package]));
}

$this->afterRun();
Expand Down
6 changes: 3 additions & 3 deletions src/console/QueueController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ private function attachEventHandlers()
$this->stdout(Console::renderColoredString($string));
};

Event::on(Queue::class, Queue::EVENT_BEFORE_WORK, function ($event) use ($out) {
Event::on(Queue::class, Queue::EVENT_BEFORE_EXEC, function ($event) use ($out) {
/** @var JobEvent $event */
$out("%GNew job%n '" . get_class($event->job) . "'\n");
});

Event::on(Queue::class, Queue::EVENT_AFTER_WORK, function ($event) use ($out) {
Event::on(Queue::class, Queue::EVENT_AFTER_EXEC, function ($event) use ($out) {
/** @var JobEvent $event */
$out("%GJob%n '" . get_class($event->job) . "' %Gis completed%n\n");
});

Event::on(Queue::class, Queue::EVENT_AFTER_ERROR, function ($event) use ($out) {
Event::on(Queue::class, Queue::EVENT_AFTER_EXEC_ERROR, function ($event) use ($out) {
/** @var ErrorEvent $event */
$out("%RJob '" . get_class($event->job) . "' finished with error:%n '" . $event->error . "'\n");
});
Expand Down

0 comments on commit b07d11b

Please sign in to comment.