lib/components/db/behaviors/auditable/AuditDataProvider.php
public function handleInstructions($params)
    {
        $this->clearParams($params);
        //\d($params);
        $this->scope = ArrayHelper::getValue($params, 'scope', 'watching');
        $direction = $this->direction = ArrayHelper::getValue($params, 'direction', '_older');
        $limit = ArrayHelper::getValue($params, 'limit', 25);
        $object = $this->context = ArrayHelper::getValue($params, 'object', false);
        if ($direction === '_newer') {
            $mostRecentItem = ArrayHelper::getValue($params, 'mostRecentItem', false);
            $this->query->andWhere($this->query->primaryAlias . '.[[created]] > FROM_UNIXTIME(' . (float) $mostRecentItem .')');
            $this->query->orderBy([$this->query->primaryAlias . '.[[created]]' => SORT_DESC]);
            $this->pagination->pageSize = false;
            //\d(["newer", $this->query->createCommand()->rawSql]);exit;
        } else { // _older
            $this->pagination->pageSize = $limit;
            $lastTime = ArrayHelper::getValue($params, 'lastItemTimestamp', false);
            $lastItem = ArrayHelper::getValue($params, 'lastItem', false);
            if ($lastItem) {
                $this->query->andWhere($this->query->primaryAlias . '.[[created]] < FROM_UNIXTIME(' . (float) $lastItem .')');
            }
            $this->query->orderBy([$this->query->primaryAlias . '.[[created]]' => SORT_DESC]); //SORT_ASC
            //\d($lastTime);
            //echo $this->query->createCommand()->rawSql;exit;
        }

        if ($this->scope === 'object' && $object) {
            $this->query->andWhere(['or',
                [$this->query->primaryAlias . '.direct_object_id' => $object],
                [$this->query->primaryAlias . '.indirect_object_id' => $object], ]);
        } elseif ($this->scope !== 'all' && !empty(Yii::$app->user->id)) {
            $subquery = ObjectFamiliarity::find();
            $subquery->andWhere([$subquery->primaryAlias . '.user_id' => Yii::$app->user->id]);
            if ($this->scope === 'watching') {
                $subquery->andWhere([$subquery->primaryAlias . '.watching' => 1]);
            }
            $subquery->select(['object_id']);
            $this->query->join('INNER JOIN', ['sof' => $subquery], ['or', '{{sof}}.[[object_id]] = {{' . $this->query->primaryAlias . '}}.[[direct_object_id]]', '{{sof}}.[[object_id]] = {{' . $this->query->primaryAlias . '}}.[[indirect_object_id]]']);
            $this->query->distinct = true;
        } else {
            $this->scope = 'all';
        }
    }
public function handleInstructions($params)
    {
        $this->clearParams($params);
        //\d($params);
        $this->scope = ArrayHelper::getValue($params, 'scope', 'watching');
        $direction = $this->direction = ArrayHelper::getValue($params, 'direction', '_older');
        $limit = ArrayHelper::getValue($params, 'limit', 25);
        $object = $this->context = ArrayHelper::getValue($params, 'object', false);
        if ($direction === '_newer') {
            $mostRecentItem = ArrayHelper::getValue($params, 'mostRecentItem', false);
            $this->query->andWhere($this->query->primaryAlias . '.[[created]] > FROM_UNIXTIME(' . (float) $mostRecentItem .')');
            $this->query->orderBy([$this->query->primaryAlias . '.[[created]]' => SORT_DESC]);
            $this->pagination->pageSize = false;
            //\d(["newer", $this->query->createCommand()->rawSql]);exit;
        } else { // _older
            $this->pagination->pageSize = $limit;
            $lastTime = ArrayHelper::getValue($params, 'lastItemTimestamp', false);
            $lastItem = ArrayHelper::getValue($params, 'lastItem', false);
            if ($lastItem) {
                $this->query->andWhere($this->query->primaryAlias . '.[[created]] < FROM_UNIXTIME(' . (float) $lastItem .')');
            }
            $this->query->orderBy([$this->query->primaryAlias . '.[[created]]' => SORT_DESC]); //SORT_ASC
            //\d($lastTime);
            //echo $this->query->createCommand()->rawSql;exit;
        }

        if ($this->scope === 'object' && $object) {
            $this->query->andWhere(['or',
                [$this->query->primaryAlias . '.direct_object_id' => $object],
                [$this->query->primaryAlias . '.indirect_object_id' => $object], ]);
        } elseif ($this->scope !== 'all' && !empty(Yii::$app->user->id)) {
            $subquery = ObjectFamiliarity::find();
            $subquery->andWhere([$subquery->primaryAlias . '.user_id' => Yii::$app->user->id]);
            if ($this->scope === 'watching') {
                $subquery->andWhere([$subquery->primaryAlias . '.watching' => 1]);
            }
            $subquery->select(['object_id']);
            $this->query->join('INNER JOIN', ['sof' => $subquery], ['or', '{{sof}}.[[object_id]] = {{' . $this->query->primaryAlias . '}}.[[direct_object_id]]', '{{sof}}.[[object_id]] = {{' . $this->query->primaryAlias . '}}.[[indirect_object_id]]']);
            $this->query->distinct = true;
        } else {
            $this->scope = 'all';
        }
    }
public function handleInstructions ( $ params ) { $ this -> clearParams ( $ params ) ; //\d($params); $ this -> scope = ArrayHelper :: getValue ( $ params , 'scope' , 'watching' ) ; $ direction = $ this -> direction = ArrayHelper :: getValue ( $ params , 'direction' , '_older' ) ; $ limit = ArrayHelper :: getValue ( $ params , 'limit' , 25 ) ; $ object = $ this -> context = ArrayHelper :: getValue ( $ params , 'object' , false ) ; if ( $ direction === '_newer' ) { $ mostRecentItem = ArrayHelper :: getValue ( $ params , 'mostRecentItem' , false ) ; $ this -> query -> andWhere ( $ this -> query -> primaryAlias . '.[[created]] > FROM_UNIXTIME(' . ( float ) $ mostRecentItem . ')' ) ; $ this -> query -> orderBy ( [ $ this -> query -> primaryAlias . '.[[created]]' => SORT_DESC ] ) ; $ this -> pagination -> pageSize = false ; //\d(["newer", $this->query->createCommand()->rawSql]);exit; } else { // _older $ this -> pagination -> pageSize = $ limit ; $ lastTime = ArrayHelper :: getValue ( $ params , 'lastItemTimestamp' , false ) ; $ lastItem = ArrayHelper :: getValue ( $ params , 'lastItem' , false ) ; if ( $ lastItem ) { $ this -> query -> andWhere ( $ this -> query -> primaryAlias . '.[[created]] < FROM_UNIXTIME(' . ( float ) $ lastItem . ')' ) ; } $ this -> query -> orderBy ( [ $ this -> query -> primaryAlias . '.[[created]]' => SORT_DESC ] ) ; //SORT_ASC //\d($lastTime); //echo $this->query->createCommand()->rawSql;exit; } if ( $ this -> scope === 'object' && $ object ) { $ this -> query -> andWhere ( [ 'or' , [ $ this -> query -> primaryAlias . '.direct_object_id' => $ object ] , [ $ this -> query -> primaryAlias . '.indirect_object_id' => $ object ] , ] ) ; } elseif ( $ this -> scope !== 'all' && ! empty ( Yii :: $ app -> user -> id ) ) { $ subquery = ObjectFamiliarity :: find ( ) ; $ subquery -> andWhere ( [ $ subquery -> primaryAlias . '.user_id' => Yii :: $ app -> user -> id ] ) ; if ( $ this -> scope === 'watching' ) { $ subquery -> andWhere ( [ $ subquery -> primaryAlias . '.watching' => 1 ] ) ; } $ subquery -> select ( [ 'object_id' ] ) ; $ this -> query -> join ( 'INNER JOIN' , [ 'sof' => $ subquery ] , [ 'or' , '{{sof}}.[[object_id]] = {{' . $ this -> query -> primaryAlias . '}}.[[direct_object_id]]' , '{{sof}}.[[object_id]] = {{' . $ this -> query -> primaryAlias . '}}.[[indirect_object_id]]' ] ) ; $ this -> query -> distinct = true ; } else { $ this -> scope = 'all' ; } }
[[@doctodo method_description:handleInstructions]].

@param [[@doctodo param_type:params]] $params [[@doctodo param_description:params]]
[[ @doctodo method_description : handleInstructions ]] .