Completed
Push — development ( eb9524...db4517 )
by Andrij
28:49 queued 02:09
created

Page::getPages()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 18
rs 9.4285
cc 3
eloc 12
nc 4
nop 0
1
<?php
2
3
namespace xbanners\src\BannerPagesTypes;
4
5
use CI;
6
7
/**
8
 * Created by PhpStorm.
9
 * User: mark
10
 * Date: 23.03.15
11
 * Time: 19:19
12
 */
0 ignored issues
show
introduced by
There must be no blank lines after the class comment
Loading history...
13
14
class Page extends BasePageType
15
{
0 ignored issues
show
introduced by
Opening brace of a class must be on the same line as the definition
Loading history...
16
17
    public function __construct($locale) {
18
        $this->locale = $locale;
19
        $this->localeId = $this->getLocaleId();
20
        $this->tpl_name = 'page';
21
    }
22
23
    public function getPages() {
24
        $pages = CI::$APP->db
25
            ->where('lang', $this->localeId)
26
            ->order_by('title')
27
            ->get('content');
28
29
        $pages = $pages ? $pages->result_array() : [];
30
31
        $data = [];
32
        foreach ($pages as $page) {
33
            $data[$page['id']] = [
34
                'id' => $page['id'],
35
                'name' => $page['title'],
36
            ];
37
        }
38
39
        return $data;
40
    }
41
}