|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* @copyright Copyright (C) 2019 Sergio coderius <coderius> |
|
4
|
|
|
* @license This program is free software: the MIT License (MIT) |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace coderius\hitCounter; |
|
8
|
|
|
|
|
9
|
|
|
use Yii; |
|
10
|
|
|
use yii\web\GroupUrlRule; |
|
11
|
|
|
|
|
12
|
|
|
class Module extends \yii\base\Module |
|
13
|
|
|
{ |
|
14
|
|
|
/** @var string module name */ |
|
15
|
|
|
public static $moduleName = 'hitCounter'; |
|
16
|
|
|
|
|
17
|
|
|
/** @var string|null */ |
|
18
|
|
|
public $userIdentityClass = null; |
|
19
|
|
|
|
|
20
|
|
|
public $controllerNamespace = 'coderius\hitCounter\controllers'; |
|
21
|
|
|
|
|
22
|
|
|
public function init() |
|
23
|
|
|
{ |
|
24
|
|
|
parent::init(); |
|
25
|
|
|
|
|
26
|
|
|
\Yii::configure($this, require __DIR__ . '/config/main.php'); |
|
27
|
|
|
|
|
28
|
|
|
//иначе ломает консольные комманды |
|
29
|
|
|
if (Yii::$app instanceof yii\web\Application) { |
|
30
|
|
|
if ($this->userIdentityClass === null) { |
|
31
|
|
|
$this->userIdentityClass = \Yii::$app->getUser()->identityClass; |
|
32
|
|
|
} |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
// var_dump(Module::t('messages', 'No comments yet.'));die; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Adds UrlManager rules. |
|
40
|
|
|
* |
|
41
|
|
|
* @param Application $app the application currently running |
|
|
|
|
|
|
42
|
|
|
*/ |
|
43
|
|
|
public function addUrlManagerRules($app) |
|
44
|
|
|
{ |
|
45
|
|
|
$app->urlManager->addRules([new GroupUrlRule([ |
|
46
|
|
|
'prefix' => $this->id, |
|
47
|
|
|
'rules' => require __DIR__ . '/config/_routes.php', |
|
48
|
|
|
])], true); |
|
49
|
|
|
|
|
50
|
|
|
// var_dump(\Yii::$app->urlManager); |
|
51
|
|
|
// var_dump($this->id.'s'); |
|
52
|
|
|
// die; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return static |
|
57
|
|
|
*/ |
|
58
|
|
|
public static function selfInstance() |
|
59
|
|
|
{ |
|
60
|
|
|
return \Yii::$app->getModule(static::$moduleName); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Get default model classes. |
|
65
|
|
|
*/ |
|
66
|
|
|
public function getDefaultModels() |
|
67
|
|
|
{ |
|
68
|
|
|
return [ |
|
69
|
|
|
'HitCounter' => \coderius\hitCounter\models\HitCounter::className(), |
|
70
|
|
|
]; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function model($name) |
|
74
|
|
|
{ |
|
75
|
|
|
$models = $this->getDefaultModels(); |
|
76
|
|
|
if (array_key_exists($name, $models)) { |
|
77
|
|
|
return $models[$name]; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
return false; |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths