PageRepository   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 28
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B getTreeForSelect() 0 25 6
1
<?php
2
3
namespace WebCMS\Entity;
4
5
use Gedmo\Tree\Entity\Repository\NestedTreeRepository;
6
7
class PageRepository extends NestedTreeRepository
8
{
9
    public function getTreeForSelect($order = null, $where = null)
10
    {
11
        $qb = $this->_em->createQueryBuilder();
12
13
        if ($order) {
14
            foreach ($order as $o) {
15
                $qb->addOrderBy('l.'.$o['by'], $o['dir']);
16
            }
17
        }
18
19
        if ($where) {
20
            foreach ($where as $w) {
21
                $qb->andWhere('l.'.$w);
22
            }
23
        }
24
25
        $tree = $qb->select('l')->from("WebCMS\Entity\Page", 'l')->getQuery()->getResult();
26
27
        $array = array();
28
        foreach ($tree as $node) {
29
            $array[$node->getId()] = str_repeat("-", $node->getLevel()).$node->getTitle();
30
        }
31
32
        return $array;
33
    }
34
}
35