ProviderActiveQuery::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/patron/license
6
 * @link       https://www.flipboxfactory.com/software/patron/
7
 */
8
9
namespace flipbox\patron\queries;
10
11
use craft\db\QueryAbortedException;
12
use flipbox\craft\ember\queries\ActiveQuery;
13
use flipbox\craft\ember\queries\AuditAttributesTrait;
14
use flipbox\patron\records\Provider;
15
16
/**
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 1.0.0
19
 */
20
class ProviderActiveQuery extends ActiveQuery
21
{
22
    use ProviderAttributesTrait,
23
        AuditAttributesTrait;
24
25
    /**
26
     * @inheritdoc
27
     */
28
    public $orderBy = [
29
        'enabled' => SORT_DESC,
30
        'dateUpdated' => SORT_DESC
31
    ];
32
33
    /**
34
     * @inheritdoc
35
     */
36
    public function init()
37
    {
38
        $this->from = [Provider::tableName() . ' ' . Provider::tableAlias()];
39
40
        parent::init();
41
    }
42
43
    /*******************************************
44
     * PREPARE
45
     *******************************************/
46
47
    /**
48
     * @inheritdoc
49
     *
50
     * @throws QueryAbortedException if it can be determined that there won’t be any results
51
     */
52
    public function prepare($builder)
53
    {
54
        $this->applyProviderConditions();
55
        $this->applyAuditAttributeConditions();
56
57
        return parent::prepare($builder);
58
    }
59
}
60