|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Epesi\Core; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Routing\Controller as BaseController; |
|
6
|
|
|
use Epesi\Core\System\SystemCore; |
|
7
|
|
|
use Epesi\Core\System\Modules\ModuleManager; |
|
8
|
|
|
use Epesi\Core\Layout\LayoutView; |
|
9
|
|
|
use Illuminate\Support\Facades\File; |
|
10
|
|
|
|
|
11
|
|
|
class Controller extends BaseController |
|
12
|
|
|
{ |
|
13
|
|
|
public function index() |
|
14
|
|
|
{ |
|
15
|
|
|
return SystemCore::isInstalled()? redirect('home'): redirect('install'); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function install(UI $ui) |
|
19
|
|
|
{ |
|
20
|
|
|
// make sure the installation information is fresh |
|
21
|
|
|
ModuleManager::clearCache(); |
|
22
|
|
|
|
|
23
|
|
|
if (SystemCore::isInstalled()) return redirect('home'); |
|
24
|
|
|
|
|
25
|
|
|
$ui->title = __(':epesi > Installation', ['epesi' => config('epesi.app.title')]); |
|
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
$ui->initLayout('Centered'); |
|
28
|
|
|
|
|
29
|
|
|
$ui->layout->set('logo', url('logo')); |
|
30
|
|
|
$ui->layout->template->setHTML('copyright', config('epesi.app.copyright')); |
|
31
|
|
|
|
|
32
|
|
|
$ui->add(new \Epesi\Core\System\SystemInstallWizard()); |
|
33
|
|
|
|
|
34
|
|
|
return $ui->response(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function home() |
|
38
|
|
|
{ |
|
39
|
|
|
return redirect(SystemCore::isInstalled()? \Epesi\Core\HomePage\Models\HomePage::pathOfUser(): 'install'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function logo() |
|
43
|
|
|
{ |
|
44
|
|
|
$logoFile = \Epesi\Core\System\Logo\LogoSettings::getLogoFile(); |
|
45
|
|
|
|
|
46
|
|
|
return response(File::get($logoFile), 200, ['Content-type' => File::mimeType($logoFile)])->setMaxAge(604800)->setPublic(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function view(UI $ui, $module, $method = 'body', $args = []) |
|
50
|
|
|
{ |
|
51
|
|
|
$ui->initLayout(new LayoutView()); |
|
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
$alias = explode(':', $module); |
|
54
|
|
|
|
|
55
|
|
|
$moduleAlias = $alias[0]; |
|
56
|
|
|
$viewAlias = $alias[1]?? null; |
|
57
|
|
|
|
|
58
|
|
|
$view = null; |
|
59
|
|
|
if ($module = ModuleManager::getClass($moduleAlias, true)) { |
|
60
|
|
|
$viewClass = $module::view($viewAlias); |
|
61
|
|
|
|
|
62
|
|
|
if (class_exists($viewClass)) { |
|
63
|
|
|
$view = new $viewClass(); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
if (! $view) abort(404); |
|
68
|
|
|
|
|
69
|
|
|
$ui->add($view)->displayModuleContent($method, $args); |
|
70
|
|
|
|
|
71
|
|
|
$ui->setLocation($view->location()); |
|
72
|
|
|
|
|
73
|
|
|
return $ui->response(); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
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.