-
Notifications
You must be signed in to change notification settings - Fork 3
/
Module.php
37 lines (29 loc) · 919 Bytes
/
Module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace spk\scheduler;
use yii;
class Module extends \yii\base\Module
{
public $defaultRoute = 'scheduler';
public $defaultFolder;
public $folderDepth = 0;
public function init()
{
parent::init();
if (Yii::$app instanceof \yii\console\Application) {
$this->controllerNamespace = 'spk\scheduler\console';
} else {
$this->controllerNamespace = 'spk\scheduler\controllers';
if (!isset($this->defaultFolder)) {
$this->defaultFolder = Yii::getAlias('@app') . DIRECTORY_SEPARATOR . 'models';
}
}
}
public function createController($route)
{
preg_match("/{$this->defaultRoute}/", $route, $match);
if (isset($match[0])) {
return parent::createController($route);
}
return parent::createController("{$this->defaultRoute}/{$route}");
}
}