/**
  * Check if my lock-file is still alive and contains my pid
  *
  * @return bool if lock file is valid then true
  *
  * @throws \yii\base\InvalidParamException
  */
 protected function isLockAlive()
 {
     $lockFile = Yii::getAlias(QueueManager::getInstance()->lockFile);
     if (file_exists($lockFile)) {
         $lockingPID = (int) trim(file_get_contents($lockFile));
         if ($lockingPID === getmypid()) {
             return true;
         }
     }
     return false;
 }
 public static function getDb()
 {
     //        return Yii::$app->db_common;
     $instance = QueueManager::getInstance();
     if ($instance === NULL) {
         throw new ErrorException('You should use this class through yii2-status module.');
     } elseif (!$instance->db) {
         $db = 'db';
     } else {
         $db = $instance->db;
     }
     return Yii::$app->get($db);
 }
 /**
  * {@inherit}
  *
  * @return array
  */
 public function behaviors()
 {
     return ['access' => ['class' => QueueManager::getInstance()->accessClass]];
 }
 /**
  * check access rights for current user
  */
 protected function checkAccess($rightName, $access = null)
 {
     if (is_null($access)) {
         $class = \queue\QueueManager::getInstance()->accessClass;
         $access = new $class();
     }
     if (!$access->isAllowed($rightName)) {
         throw new ForbiddenHttpException(Yii::t('wallets', 'Access restricted'));
     }
 }