BaseTermBehavior::getQuery()   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
  * User: Phreak
4
 * Date: 13.02.2015
5
 * Time: 09:31 ч.
6
 */
7
8
namespace nkostadinov\taxonomy\behaviors;
9
10
use nkostadinov\taxonomy\models\TaxonomyTerms;
11
use yii\base\Behavior;
12
13
class BaseTermBehavior extends Behavior
14
{
15
    /** @property BaseTerm $taxonomy */
16
    public $taxonomy;
17
18
    protected function joinTables()
19
    {
20
        /** @var ActiveRecord $model */
21
        $model = new $this->owner->modelClass();
22
23
        /** @var ActiveRecord $this->owner */
24
        $this->getQuery()
25
            ->leftJoin($this->taxonomy->table, $this->taxonomy->table . '.object_id = ' . $model::tableName() . '.id')
26
            ->leftJoin(TaxonomyTerms::tableName(), TaxonomyTerms::tableName() . '.id = ' . $this->taxonomy->table . '.term_id');
27
    }
28
29
    /**
30
     * @return ActiveQuery
31
     */
32
    public function getQuery()
33
    {
34
        return $this->owner;
35
    }
36
}