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

mod/pages/views/default/input/pages/parent.php (1 issue)

1
<?php
2
/**
3
 * Parent picker
4
 *
5
 * @uses $vars['value']          The current value, if any
6
 * @uses $vars['options_values']
7
 * @uses $vars['name']           The name of the input field
8
 * @uses $vars['entity']         Optional. The child entity (uses container_guid)
9
 */
10
11
$entity = elgg_extract('entity', $vars);
12
if ($entity instanceof ElggPage) {
13
	$container = $entity->getContainerEntity();
14
} else {
15
	$container = elgg_get_page_owner_entity();
16
}
17
18
$pages = pages_get_navigation_tree($container);
0 ignored issues
show
It seems like $container can also be of type false; however, parameter $container of pages_get_navigation_tree() does only seem to accept ElggEntity, maybe add an additional type check? ( Ignorable by Annotation )

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

18
$pages = pages_get_navigation_tree(/** @scrutinizer ignore-type */ $container);
Loading history...
19
20
$options = [];
21
foreach ($pages as $page) {
22
	$spacing = '';
23
	$spacing .= str_repeat('--', $page['depth']);
24
	
25
	$options[$page['guid']] = "$spacing " . $page['title'];
26
}
27
28
$defaults = [
29
	'class' => 'elgg-pages-input-parent-picker',
30
	'options_values' => $options,
31
];
32
33
$vars = array_merge($defaults, $vars);
34
35
echo elgg_view('input/select', $vars);
36