Skip to content

Commit 5e63887

Browse files
author
Igor Chepurnoy
committed
Update MutexConsoleCommandBehavior.php
1 parent 7b0efaa commit 5e63887

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

behaviors/MutexConsoleCommandBehavior.php

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
11
<?php
2+
23
namespace yii2mod\cron\behaviors;
34

5+
use Yii;
46
use yii\base\Behavior;
57
use yii\console\Controller;
8+
use yii\mutex\Mutex;
69

710

811
/**
912
* MutexConsoleCommandBehavior allows console command actions being run with mutex protection.
1013
*
1114
* Usage:
12-
* <code>
15+
* ```
1316
* class MyCommand extends Controller
1417
* {
1518
* public function behaviors()
1619
* {
17-
* return array(
18-
* 'mutexBehavior' => array(
20+
* return [
21+
* 'mutexBehavior' => [
1922
* 'class' => 'yii2mod\cron\behaviors\MutexConsoleCommandBehavior',
20-
* 'mutexActions' => array('index'), // OR ['*'] - attach to all actions
21-
* ),
22-
* );
23+
* 'mutexActions' => ['index'], // OR ['*'] - attach to all actions
24+
* ]
25+
* ];
2326
* }
2427
* }
25-
* </code>
26-
*
27-
* @method \Controller getOwner()
28+
* ```
2829
*
29-
* @author Klimov Paul <klimov@zfort.com>
30-
* @author Dmitry Semenov <disemx@gmail.com>
31-
* @version $Id$
30+
* Class MutexConsoleCommandBehavior
3231
* @package yii2mod\cron\behaviors
33-
* @since 1.0
3432
*/
3533
class MutexConsoleCommandBehavior extends Behavior
3634
{
@@ -41,7 +39,7 @@ class MutexConsoleCommandBehavior extends Behavior
4139
/**
4240
* @var array list of action names, which mutex should be applied to.
4341
*/
44-
public $mutexActions = array();
42+
public $mutexActions = [];
4543

4644

4745
/**
@@ -60,7 +58,7 @@ public function events()
6058
*/
6159
public function getMutex()
6260
{
63-
return \Yii::$app->get($this->mutex);
61+
return Yii::$app->get($this->mutex);
6462
}
6563

6664
/**

0 commit comments

Comments
 (0)