|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* _ __ __ _____ _____ ___ ____ _____ |
|
5
|
|
|
* | | / // // ___//_ _// || __||_ _| |
|
6
|
|
|
* | |/ // /(__ ) / / / /| || | | | |
|
7
|
|
|
* |___//_//____/ /_/ /_/ |_||_| |_| |
|
8
|
|
|
* @link https://vistart.me/ |
|
9
|
|
|
* @copyright Copyright (c) 2016 - 2017 vistart |
|
10
|
|
|
* @license https://vistart.me/license/ |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace rhosocial\user\web\user\controllers; |
|
14
|
|
|
|
|
15
|
|
|
use yii\web\Controller; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* My Controller. |
|
19
|
|
|
* The controller is only used as a demonstration, you need to develop and cover |
|
20
|
|
|
* the controller and view yourself. |
|
21
|
|
|
* The specific apporach is as follow: |
|
22
|
|
|
* |
|
23
|
|
|
* First, you need to implement `MyController` and corresponding view(s), for example: |
|
24
|
|
|
```php |
|
25
|
|
|
namespace app\controllers; |
|
26
|
|
|
|
|
27
|
|
|
use yii\web\Controller; |
|
28
|
|
|
|
|
29
|
|
|
class MyController extends Controller |
|
30
|
|
|
{ |
|
31
|
|
|
public $layout = '//main'; // If you want to use your own layout, please assign a absolute path. |
|
32
|
|
|
public function actionIndex() |
|
33
|
|
|
{ |
|
34
|
|
|
return $this->render('//my/index'); // If you want to use your own view, please pass a absolute path. |
|
35
|
|
|
} |
|
36
|
|
|
... |
|
37
|
|
|
} |
|
38
|
|
|
``` |
|
39
|
|
|
* Then, you need to specify your own controller in the module's controllerMap property: |
|
40
|
|
|
``` |
|
41
|
|
|
'modules' => [ |
|
42
|
|
|
'user' => [ |
|
43
|
|
|
'class' => 'rhosocial\user\web\user\Module, |
|
44
|
|
|
'controllerMap' => [ |
|
45
|
|
|
'my' => [ |
|
46
|
|
|
'class' => 'app\controllers\MyController', |
|
47
|
|
|
], |
|
48
|
|
|
], |
|
49
|
|
|
], |
|
50
|
|
|
], |
|
51
|
|
|
``` |
|
52
|
|
|
* @version 1.0 |
|
53
|
|
|
* @author vistart <[email protected]> |
|
54
|
|
|
*/ |
|
55
|
|
|
class MyController extends Controller |
|
56
|
|
|
{ |
|
57
|
|
|
public function actionIndex() |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->render('index'); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|