1
|
|
|
<?php
|
2
|
|
|
/**
|
3
|
|
|
* @author Sergey Glagolev <[email protected]>
|
4
|
|
|
* @link https://github.com/shogodev/argilla/
|
5
|
|
|
* @copyright Copyright © 2003-2014 Shogo
|
6
|
|
|
* @license http://argilla.ru/LICENSE
|
7
|
|
|
* @package frontend.components
|
8
|
|
|
*
|
9
|
|
|
* @property FController $controller
|
10
|
|
|
* @property SClientScript $clientScript
|
11
|
|
|
* @property SAssetManager $assetManager
|
12
|
|
|
* @property ScriptsFactory $mainscript
|
13
|
|
|
* @property FWebUser $user
|
14
|
|
|
* @property FUrlManager $urlManager
|
15
|
|
|
* @property SFormatter $format
|
16
|
|
|
* @property Email $email
|
17
|
|
|
* @property SNotification $notification
|
18
|
|
|
* @property RequestRedirectComponent $requestRedirect
|
19
|
|
|
* @property EPhpThumb $phpThumb
|
20
|
|
|
* @property Meta $meta
|
21
|
|
|
* @property CAttributeCollection $params
|
22
|
|
|
*/
|
23
|
|
|
class FApplication extends CWebApplication
|
24
|
|
|
{
|
25
|
|
|
/**
|
26
|
|
|
* @param CController $controller
|
27
|
|
|
* @param CAction $action
|
28
|
|
|
*
|
29
|
|
|
* @return bool
|
30
|
|
|
*/
|
31
|
22 |
|
public function beforeControllerAction($controller, $action)
|
32
|
|
|
{
|
33
|
22 |
|
$this->getComponent('meta');
|
34
|
22 |
|
$this->onBeforeControllerAction(new CEvent($this));
|
35
|
|
|
|
36
|
22 |
|
return parent::beforeControllerAction($controller, $action);
|
37
|
|
|
}
|
38
|
|
|
|
39
|
22 |
|
public function onBeforeControllerAction(CEvent $event)
|
40
|
|
|
{
|
41
|
22 |
|
$this->raiseEvent('onBeforeControllerAction', $event);
|
42
|
22 |
|
}
|
43
|
|
|
|
44
|
|
|
protected function init()
|
45
|
|
|
{
|
46
|
|
|
parent::init();
|
47
|
|
|
|
48
|
|
|
$this->setProjectName();
|
49
|
|
|
}
|
50
|
|
|
|
51
|
|
|
protected function setProjectName()
|
|
|
|
|
52
|
|
|
{
|
53
|
|
|
if( empty($this->params->project) && isset($_SERVER['SERVER_NAME']) )
|
54
|
|
|
{
|
55
|
|
|
$this->params->project = preg_replace("/^www./", '', Yii::app()->request->getServerName());
|
56
|
|
|
}
|
57
|
|
|
}
|
58
|
|
|
} |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: