1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace luya\web; |
4
|
|
|
|
5
|
|
|
use luya\traits\ApplicationTrait; |
6
|
|
|
use yii\web\ForbiddenHttpException; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Luya Web Application. |
10
|
|
|
* |
11
|
|
|
* |
12
|
|
|
* @property \luya\cms\Menu $menu Menu component in order to build navigation from CMS module. |
13
|
|
|
* @property \luya\admin\storage\BaseFileSystemStorage $storage Storage component for reading, saving and holding files from the Admin module. |
14
|
|
|
* @property \luya\web\Composition $composition Composition component. |
15
|
|
|
* @property \luya\web\Element $element The element component. |
16
|
|
|
* @property \luya\web\View $view The view component. |
17
|
|
|
* @property \luya\web\Request $request The request component. |
18
|
|
|
* @property \luya\web\ErrorHandler $errorHandler The error handler component. |
19
|
|
|
* |
20
|
|
|
* @author Basil Suter <[email protected]> |
21
|
|
|
* @since 1.0.0 |
22
|
|
|
*/ |
23
|
|
|
class Application extends \yii\web\Application |
24
|
|
|
{ |
25
|
|
|
use ApplicationTrait; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @inheritdoc |
29
|
|
|
*/ |
30
|
|
|
public function handleRequest($request) |
31
|
|
|
{ |
32
|
|
|
if ($this->ensureSecureConnection && !$request->isSecureConnection) { |
33
|
|
|
throw new ForbiddenHttpException("Insecure connection is not allowed."); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
return parent::handleRequest($request); |
|
|
|
|
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @inheritdoc |
41
|
|
|
*/ |
42
|
|
|
public function coreComponents() |
43
|
|
|
{ |
44
|
|
|
return array_merge($this->luyaCoreComponents(), [ |
|
|
|
|
45
|
|
|
'request' => ['class' => 'luya\web\Request'], |
46
|
|
|
'errorHandler' => ['class' => 'luya\web\ErrorHandler'], |
47
|
|
|
'urlManager' => ['class' => 'luya\web\UrlManager'], |
48
|
|
|
'view' => ['class' => 'luya\web\View'], |
49
|
|
|
'element' => ['class' => 'luya\web\Element'], |
50
|
|
|
'composition' => ['class' => 'luya\web\Composition'], |
51
|
|
|
'assetManager' => [ |
52
|
|
|
'class' => 'luya\web\AssetManager', |
53
|
|
|
'forceCopy' => YII_DEBUG, |
54
|
|
|
'appendTimestamp' => !YII_DEBUG, |
55
|
|
|
], |
56
|
|
|
]); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.