Skip to content

Commit a66ff38

Browse files
author
Igor Chepurnoy
authored
Update CronLoggerBehavior.php
1 parent dcad22c commit a66ff38

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

behaviors/CronLoggerBehavior.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Yii;
66
use yii\base\Behavior;
77
use yii\console\Controller;
8+
use yii\helpers\ArrayHelper;
89
use yii2mod\cron\models\CronScheduleModel;
910
use yii2mod\cron\models\enumerables\CronScheduleStatus;
1011

@@ -69,7 +70,7 @@ public function beforeAction($event)
6970
{
7071
if (in_array($event->action->id, $this->actions) || in_array('*', $this->actions)) {
7172
$sender = $event->sender;
72-
$command = $sender->id . '/' . $sender->action->id;
73+
$command = $sender->id . '/' . $sender->action->id . $this->getActionParams();
7374
$this->schedule = new CronScheduleModel();
7475
$this->schedule->startCronSchedule($command);
7576
$this->setupApplicationErrorHandlers();
@@ -101,4 +102,26 @@ protected function setupApplicationErrorHandlers()
101102
$errorHandler = Yii::$app->get('errorHandler');
102103
$errorHandler->schedule = &$this->schedule;
103104
}
104-
}
105+
106+
/**
107+
* Get action params
108+
*
109+
* @return string
110+
*/
111+
private function getActionParams()
112+
{
113+
$result = '';
114+
$requestParams = Yii::$app->request->getParams();
115+
ArrayHelper::remove($requestParams, 0);
116+
117+
foreach ($requestParams as $key => $value) {
118+
if (is_string($key)) {
119+
$result .= " --{$key}={$value}";
120+
} else {
121+
$result .= " {$value}";
122+
}
123+
}
124+
125+
return $result;
126+
}
127+
}

0 commit comments

Comments
 (0)