1 | <?php |
||
12 | class BaseController extends Controller |
||
13 | { |
||
14 | /** |
||
15 | * @var string Path to js bundle |
||
16 | */ |
||
17 | public $jsBundle = 'front.js'; |
||
18 | /** |
||
19 | * @var string Path to css bundle |
||
20 | */ |
||
21 | public $cssBundle = 'front.css'; |
||
22 | |||
23 | /** |
||
24 | * @return string Return CSS bundle |
||
25 | */ |
||
26 | public function getCssBundle() |
||
30 | |||
31 | /** |
||
32 | * @return string Return JS bundle |
||
33 | */ |
||
34 | public function getJsBundle() |
||
38 | |||
39 | /** |
||
40 | * Load the model based on its primary key value or WHERE condition. |
||
41 | * If the model is not found or access denied, a 404 HTTP exception will be thrown. |
||
42 | * |
||
43 | * @param ActiveRecord $model |
||
44 | * @param int|array $id primary key or WHERE condition |
||
45 | * @param bool $ownerCheck |
||
46 | * @return ActiveRecord |
||
47 | * @throws HttpException |
||
48 | */ |
||
49 | public function loadModel($model, $id, $ownerCheck = false) |
||
63 | |||
64 | /** |
||
65 | * Show alert message |
||
66 | * |
||
67 | * @param string $type success|error |
||
68 | * @param string $message |
||
69 | * @param string $url If null go Home |
||
70 | */ |
||
71 | public function alert($type, $message, $url = null) |
||
76 | |||
77 | /** |
||
78 | * Response |
||
79 | * |
||
80 | * @param mixed $data |
||
81 | * @param string $format The response format |
||
82 | * @see http://www.yiiframework.com/doc-2.0/yii-web-response.html |
||
83 | */ |
||
84 | public function response($data, $format = \yii\web\Response::FORMAT_JSON) |
||
89 | |||
90 | /** |
||
91 | * Triggers a 404 (Page Not Found) error |
||
92 | * |
||
93 | * @param string $msg |
||
94 | * @throws HttpException when invoked |
||
95 | */ |
||
96 | public function pageNotFound($msg = null) |
||
100 | |||
101 | /** |
||
102 | * Triggers a 403 (Access Denied) error |
||
103 | * |
||
104 | * @param string $msg |
||
105 | * @throws HttpException when invoked |
||
106 | */ |
||
107 | public function accessDenied($msg = null) |
||
111 | |||
112 | /** |
||
113 | * Triggers a 400 (Bad Request) error |
||
114 | * |
||
115 | * @param string $msg |
||
116 | * @throws HttpException when invoked |
||
117 | */ |
||
118 | public function badRequest($msg = null) |
||
122 | } |
||
123 |