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

elgg_activity_init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 11
ccs 6
cts 6
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Register menu items for the title menu
5
 *
6
 * @param string $hook   Hook
7
 * @param string $type   Type
8
 * @param array  $return Current return value
9
 * @param array  $params Hook parameters
10
 * @return array
11
 *
12
 * @access private
13
 *
14
 * @since 3.0
15
 */
16
function _elgg_activity_owner_block_menu($hook, $type, $return, $params) {
2 ignored issues
show
Unused Code introduced by jdalsem
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

16
function _elgg_activity_owner_block_menu($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...
Unused Code introduced by jdalsem
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

16
function _elgg_activity_owner_block_menu(/** @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...
17
18
	$entity = elgg_extract('entity', $params);
19
	
20
	if ($entity instanceof \ElggUser) {
21
		$return[] = \ElggMenuItem::factory([
22
			'name' => 'activity:owner',
23
			'text' => elgg_echo('activity:owner'),
24
			'href' => elgg_generate_url('collections:river:owner', ['username' => $entity->username]),
25
		]);
26
	}
27
	
28
	return $return;
29
}
30
31
/**
32
 * Called during system init
33
 *
34
 * @return void
35
 */
36
function elgg_activity_init() {
37
	
38 31
	elgg_extend_view('css/elgg', 'river/filter.css');
39
	
40 31
	elgg_register_menu_item('site', [
41 31
		'name' => 'activity',
42 31
		'text' => elgg_echo('activity'),
43 31
		'href' => elgg_generate_url('default:river'),
44
	]);
45
	
46 31
	elgg_register_plugin_hook_handler('register', 'menu:owner_block', '_elgg_activity_owner_block_menu');
47 31
}
48
49
return function() {
50 18
	elgg_register_event_handler('init', 'system', 'elgg_activity_init');
51
};
52