Class yii\debug\models\timeline\Search

Inheritanceyii\debug\models\timeline\Search » yii\debug\models\search\Base » yii\base\Model
Available since extension's version2.0.8
Source Code https://github.com/yiisoft/yii2-debug/blob/master/src/models/timeline/Search.php

Search model for timeline data.

Public Properties

Hide inherited properties

Property Type Description Defined By
$category string Attribute search yii\debug\models\timeline\Search
$duration integer Attribute search yii\debug\models\timeline\Search

Public Methods

Hide inherited methods

Method Description Defined By
addCondition() Adds filtering condition for a given attribute yii\debug\models\search\Base
attributeLabels() yii\debug\models\timeline\Search
rules() yii\debug\models\timeline\Search
search() Returns data provider with filled models. Filter applied if needed. yii\debug\models\timeline\Search

Property Details

Hide inherited properties

$category public property

Attribute search

public string $category null
$duration public property

Attribute search

public integer $duration 0

Method Details

Hide inherited methods

addCondition() public method

Defined in: yii\debug\models\search\Base::addCondition()

Adds filtering condition for a given attribute

public void addCondition ( yii\debug\components\search\Filter $filter, $attribute, $partial false )
$filter yii\debug\components\search\Filter

Filter instance

$attribute string

Attribute to filter

$partial boolean

If partial match should be used

                public function addCondition(Filter $filter, $attribute, $partial = false)
{
    $value = $this->$attribute;
    if (mb_strpos($value, '>') !== false) {
        $value = (int) str_replace('>', '', $value);
        $filter->addMatcher($attribute, new matchers\GreaterThan(['value' => $value]));
    } elseif (mb_strpos($value, '<') !== false) {
        $value = (int) str_replace('<', '', $value);
        $filter->addMatcher($attribute, new matchers\LowerThan(['value' => $value]));
    } else {
        $filter->addMatcher($attribute, new matchers\SameAs(['value' => $value, 'partial' => $partial]));
    }
}

            
attributeLabels() public method

public void attributeLabels ( )

                public function attributeLabels()
{
    return [
        'duration' => 'Duration ≥'
    ];
}

            
rules() public method

public void rules ( )

                public function rules()
{
    return [
        [['category', 'duration'], 'safe'],
    ];
}

            
search() public method

Returns data provider with filled models. Filter applied if needed.

public yii\debug\models\timeline\DataProvider search ( $params, $panel )
$params array

$params an array of parameter values indexed by parameter names

$panel \yii\debug\models\timeline\TimeLinePanel

                public function search($params, $panel)
{
    $models = $panel->models;
    $dataProvider = new DataProvider($panel, [
        'allModels' => $models,
        'sort' => [
            'attributes' => ['category', 'timestamp']
        ],
    ]);
    if (!($this->load($params) && $this->validate())) {
        return $dataProvider;
    }
    $filter = new Filter();
    $this->addCondition($filter, 'category', true);
    if ($this->duration > 0) {
        $filter->addMatcher('duration', new GreaterThanOrEqual(['value' => $this->duration / 1000]));
    }
    $dataProvider->allModels = $filter->filter($models);
    return $dataProvider;
}