DashboardCore   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
eloc 29
c 4
b 0
f 1
dl 0
loc 54
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A info() 0 7 1
A boot() 0 12 3
A install() 0 17 1
1
<?php
2
3
namespace Epesi\Base\Dashboard;
4
5
use Epesi\Core\System\Modules\ModuleCore;
0 ignored issues
show
Bug introduced by
The type Epesi\Core\System\Modules\ModuleCore was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Epesi\Core\System\User\Database\Models\User;
7
8
class DashboardCore extends ModuleCore
9
{
10
	protected static $alias = 'dashboard';
11
	
12
	protected static $joints = [
13
			Integration\DashboardUserSettings::class,
14
			Integration\DashboardSystemSettings::class,
15
			Integration\DashboardNavMenu::class,
16
			Integration\DashboardHomePage::class
17
	];
18
	
19
	public function install()
20
	{
21
	    Models\Dashboard::migrate();
22
	    Models\DashboardApplet::migrate();
23
		
24
		// setup default dashboard
25
	    $dashboardId = (int) Models\Dashboard::create()->insert([
26
				'user_id' => 0,
27
				'name' => __('Admin Default')
28
		]);
29
		
30
	    Models\DashboardApplet::create()->insert([
31
	            [
32
	                    'dashboard_id' => $dashboardId,
33
	                    'class' => 'Epesi\\Applets\\Clock\\ClockApplet',
34
	                    'row' => 0,
35
	                    'column' => 3,
36
	            ]
37
	    ]);
38
	}
39
	
40
	public static function info()
41
	{
42
		return [
43
				__('Author') => 'Georgi Hristov',
44
				__('Copyright') => 'X Systems Ltd',
45
				'',
46
				'Provides dashboard functionality'
47
		];
48
	}
49
	
50
	public static function boot()
51
	{
52
		// create user default dashboard as copy of the system default
53
		User::created(function(User $user) {
54
		    if (! $defaultDashboard = Models\Dashboard::create()->addCondition('user_id', 0)->tryLoadAny()) return;
55
			$userDefaultDashboard = (clone $defaultDashboard)->duplicate()->save([
56
			        'name' => __('Default'),
57
			        'user_id' => $user->id
58
			]);
59
60
			foreach ($defaultDashboard->ref('applets') as $defaultApplet) {
61
			    $defaultApplet->duplicate()->saveAndUnload(['dashboard_id' => $userDefaultDashboard->id]);
62
			}
63
		});
64
	}
65
}
66