GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — 2.6.x (#2558)
by Nicolas
05:04
created

contentAjaxSections   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3
Metric Value
wmc 9
lcom 1
cbo 3
dl 0
loc 46
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
D view() 0 43 9
1
<?php
2
/**
3
 * @package content
4
 */
5
/**
6
 * The AjaxSections page return an object of all sections and their fields
7
 * that are available for pre-population
8
 */
9
10
class contentAjaxSections extends JSONPage
11
{
12
    public function view()
13
    {
14
        $sort = General::sanitize($_REQUEST['sort']);
15
        if (empty($sort)) {
16
            $sort = 'sortorder';
17
        }
18
        $sections = SectionManager::fetch(null, 'ASC', $sort);
19
        $options = array();
20
21
        if (is_array($sections) && !empty($sections)) {
22
            foreach ($sections as $section) {
23
                $section_fields = $section->fetchFields();
24
25
                if (!is_array($section_fields)) {
26
                    continue;
27
                }
28
29
                $fields = array();
30
31
                foreach ($section_fields as $f) {
32
                    if ($f->canPrePopulate()) {
33
                        $fields[] = array(
34
                            'id' => $f->get('id'),
35
                            'name' => $f->get('label'),
36
                            'handle' => $f->get('element_name'),
37
                            'type' => $f->get('type')
38
                        );
39
                    }
40
                }
41
42
                if (!empty($fields)) {
43
                    $options[] = array(
44
                        'id' => $section->get('id'),
45
                        'name' => $section->get('name'),
46
                        'handle' => $section->get('handle'),
47
                        'fields' => $fields
48
                    );
49
                }
50
            }
51
        }
52
53
        $this->_Result['sections'] = $options;
54
    }
55
}
56