2727 * ```
2828 *
2929 * Class MutexConsoleCommandBehavior
30+ *
3031 * @package yii2mod\cron\behaviors
3132 */
3233class MutexConsoleCommandBehavior extends Behavior
3334{
3435 /**
35- * @var string name of the mutex application component.
36+ * @var string name of the mutex application component
3637 */
3738 public $ mutex = 'mutex ' ;
3839
3940 /**
40- * @var array list of action names, which mutex should be applied to.
41+ * @var array list of action names, which mutex should be applied to
4142 */
4243 public $ mutexActions = [];
4344
@@ -53,7 +54,7 @@ public function events()
5354 }
5455
5556 /**
56- * @return Mutex mutex application component instance.
57+ * @return Mutex mutex application component instance
5758 */
5859 public function getMutex ()
5960 {
@@ -63,9 +64,9 @@ public function getMutex()
6364 /**
6465 * Composes the mutex name.
6566 *
66- * @param string $action command action name.
67+ * @param string $action command action name
6768 *
68- * @return string mutex name.
69+ * @return string mutex name
6970 */
7071 protected function composeMutexName ($ action )
7172 {
@@ -75,9 +76,9 @@ protected function composeMutexName($action)
7576 /**
7677 * Checks if specified action is among mutex actions.
7778 *
78- * @param string $action action name.
79+ * @param string $action action name
7980 *
80- * @return boolean whether action should be under mutex.
81+ * @return bool whether action should be under mutex
8182 */
8283 public function checkIsMutexAction ($ action )
8384 {
@@ -86,6 +87,7 @@ public function checkIsMutexAction($action)
8687
8788 /**
8889 * @param $event
90+ *
8991 * @return bool
9092 */
9193 public function beforeAction ($ event )
@@ -95,6 +97,7 @@ public function beforeAction($event)
9597 if (!$ this ->getMutex ()->acquire ($ mutexName )) {
9698 echo "Execution terminated: command is already running. \n" ;
9799 $ event ->isValid = false ;
100+
98101 return false ;
99102 }
100103 }
@@ -110,4 +113,4 @@ public function afterAction($event)
110113 $ this ->getMutex ()->release ($ mutexName );
111114 }
112115 }
113- }
116+ }
0 commit comments