Passed
Push — master ( c0a3a7...3b84a4 )
by Jeroen
58:51
created

dashboard_page_handler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * A user dashboard
4
 */
5
6
/**
7
 * Dashboard init
8
 *
9
 * @return void
10
 */
11
function dashboard_init() {
12 31
	elgg_register_page_handler('dashboard', 'dashboard_page_handler');
0 ignored issues
show
Deprecated Code introduced by
The function elgg_register_page_handler() has been deprecated: 3.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

12
	/** @scrutinizer ignore-deprecated */ elgg_register_page_handler('dashboard', 'dashboard_page_handler');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
13
14 31
	if (elgg_is_logged_in()) {
15
		elgg_register_menu_item('topbar', [
16
			'name' => 'dashboard',
17
			'href' => 'dashboard',
18
			'text' => elgg_echo('dashboard'),
19
			'icon' => 'th-large',
20
			'priority' => 100,
21
			'section' => 'alt',
22
			'parent_name' => 'account',
23
		]);
24
	}
25
	
26 31
	elgg_register_plugin_hook_handler('get_list', 'default_widgets', 'dashboard_default_widgets');
27 31
}
28
29
/**
30
 * Dashboard page handler
31
 *
32
 * @return bool
33
 */
34
function dashboard_page_handler() {
35
	echo elgg_view_resource('dashboard');
36
	return true;
37
}
38
39
/**
40
 * Register user dashboard with default widgets
41
 *
42
 * @param string $hook   'get_list',
43
 * @param string $type   'default_widgets'
44
 * @param array  $return current return value
45
 * @param mixed  $params supplied params
46
 *
47
 * @return array
48
 */
49
function dashboard_default_widgets($hook, $type, $return, $params) {
3 ignored issues
show
Unused Code introduced by
The parameter $params is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

49
function dashboard_default_widgets($hook, $type, $return, /** @scrutinizer ignore-unused */ $params) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $hook is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

49
function dashboard_default_widgets(/** @scrutinizer ignore-unused */ $hook, $type, $return, $params) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

49
function dashboard_default_widgets($hook, /** @scrutinizer ignore-unused */ $type, $return, $params) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
50 18
	$return[] = [
51 18
		'name' => elgg_echo('dashboard'),
52 18
		'widget_context' => 'dashboard',
53 18
		'widget_columns' => 3,
54
55 18
		'event' => 'create',
56 18
		'entity_type' => 'user',
57
		'entity_subtype' => ELGG_ENTITIES_ANY_VALUE,
58
	];
59
60 18
	return $return;
61
}
62
63
return function() {
64 18
	elgg_register_event_handler('init', 'system', 'dashboard_init');
65
};
66