|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ffcms\Core; |
|
4
|
|
|
|
|
5
|
|
|
use Ffcms\Core\Helper\Type\Arr; |
|
6
|
|
|
use Ffcms\Core\Helper\Type\Str; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class Alias - fast alias for core property's |
|
10
|
|
|
* @package Ffcms\Core |
|
11
|
|
|
*/ |
|
12
|
|
|
class Alias |
|
13
|
|
|
{ |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Absolute path to current view folder |
|
17
|
|
|
* @var string |
|
18
|
|
|
*/ |
|
19
|
|
|
public $currentViewPath; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Return full URL of current view folder |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
public $currentViewUrl; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Current app basic domain address, obtained from request |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
public $baseDomain; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Current app basic URL without language path |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
public $baseUrlNoLang; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Current app basic URL address, obtained from request |
|
41
|
|
|
* @var string |
|
42
|
|
|
*/ |
|
43
|
|
|
public $baseUrl; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Current app basic URL without any changes in pathway(lang-defined, etc) |
|
47
|
|
|
* @var string |
|
48
|
|
|
*/ |
|
49
|
|
|
public $scriptUrl; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Alias constructor. Build alias properties for system data to provide fast-access from apps and other places. |
|
53
|
|
|
*/ |
|
54
|
|
|
public function __construct() |
|
55
|
|
|
{ |
|
56
|
|
|
// make alias for view pathway |
|
57
|
|
|
$this->currentViewPath = App::$View->getCurrentPath(); |
|
58
|
|
|
|
|
59
|
|
|
// make alias for baseUrl, script url and domain |
|
60
|
|
|
$this->baseDomain = App::$Request->getHttpHost(); |
|
61
|
|
|
if (Str::likeEmpty($this->baseDomain)) { |
|
62
|
|
|
$this->baseDomain = App::$Properties->get('baseDomain'); |
|
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
// build script url |
|
65
|
|
|
$this->scriptUrl = App::$Request->getScheme() . '://' . $this->baseDomain; |
|
66
|
|
|
if (App::$Properties->get('basePath') !== '/') { |
|
67
|
|
|
$this->scriptUrl .= rtrim(App::$Properties->get('basePath'), '/'); |
|
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
// build base url (with current used interface path slug) |
|
70
|
|
|
$this->baseUrl = $this->scriptUrl; |
|
71
|
|
|
if (App::$Request->getInterfaceSlug() !== null) { |
|
|
|
|
|
|
72
|
|
|
$this->baseUrl .= App::$Request->getInterfaceSlug(); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
$this->baseUrlNoLang = $this->baseUrl; |
|
76
|
|
|
if (App::$Request->languageInPath() && App::$Request->getLanguage() !== null) { |
|
77
|
|
|
$this->baseUrl .= '/' . App::$Request->getLanguage(); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
// @todo: add cron initiation from user if enabled -> move to layout |
|
81
|
|
|
//if ((bool)App::$Properties->get('userCron') && env_name === 'Front') { |
|
|
|
|
|
|
82
|
|
|
// $this->addPlainCode('js', 'if(Math.random() > 0.8) { $.get("' . $this->scriptUrl . '/cron.php?rand=" + Math.random()); }'); |
|
|
|
|
|
|
83
|
|
|
//} |
|
|
|
|
|
|
84
|
|
|
|
|
85
|
|
|
$themeAll = App::$Properties->get('theme'); |
|
86
|
|
|
if (!isset($themeAll[env_name]) || Str::length($themeAll[env_name]) < 1) { |
|
|
|
|
|
|
87
|
|
|
$themeAll[env_name] = 'default'; |
|
88
|
|
|
} |
|
89
|
|
|
$this->currentViewUrl = $this->scriptUrl . '/Apps/View/' . env_name . '/' . $themeAll[env_name]; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.