Filter::isActive()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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