Completed
Push — 1.2 ( d3ea0d...d8c512 )
by David
16:21
created

Filter::getWhere()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\DoctrinePHPCRAdminBundle\Filter;
13
14
use Sonata\AdminBundle\Filter\Filter as BaseFilter;
15
use Sonata\DoctrinePHPCRAdminBundle\Datagrid\ProxyQuery;
16
17
abstract class Filter extends BaseFilter
18
{
19
    /**
20
     * @var boolean
21
     */
22
    protected $active = false;
23
24
    /**
25
     * @param ProxyQuery $queryBuilder
26
     * @param mixed      $value
27
     */
28
    public function apply($queryBuilder, $value)
29
    {
30
        $this->value = $value;
31
        $this->filter($queryBuilder, $queryBuilder->getAlias(), $this->getFieldName(), $value);
32
    }
33
34
    /**
35
     * Add the where statement for this filter to the query.
36
     *
37
     * @param ProxyQuery $proxy
38
     */
39
    protected function getWhere(ProxyQuery $proxy)
40
    {
41
        $queryBuilder = $proxy->getQueryBuilder();
42
        if ($this->getCondition() == self::CONDITION_OR) {
43
            return $queryBuilder->orWhere();
44
        }
45
46
        return $queryBuilder->andWhere();
47
    }
48
49
    /**
50
     * {@inheritDoc}
51
     */
52
    public function isActive()
53
    {
54
        return $this->active;
55
    }
56
}
57