11<?php
2+
23namespace yii2mod \cron \behaviors ;
34
5+ use Yii ;
46use yii \base \Behavior ;
57use 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 */
3533class 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