Class yii\debug\models\search\Event
Inheritance | yii\debug\models\search\Event » yii\debug\models\search\Base » yii\base\Model |
---|---|
Available since extension's version | 2.0.14 |
Source Code | https://github.com/yiisoft/yii2-debug/blob/master/src/models/search/Event.php |
Event
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$class | yii\debug\models\search\Event | ||
$isStatic | boolean | Whether event is static or not. | yii\debug\models\search\Event |
$name | yii\debug\models\search\Event | ||
$senderClass | yii\debug\models\search\Event |
Public Methods
Method | Description | Defined By |
---|---|---|
addCondition() | Adds filtering condition for a given attribute | yii\debug\models\search\Base |
attributeLabels() | yii\debug\models\search\Event | |
rules() | yii\debug\models\search\Event | |
search() | Returns data provider with filled models. Filter applied if needed. | yii\debug\models\search\Event |
Property Details
Method Details
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]));
}
}
public void attributeLabels ( ) |
public function attributeLabels()
{
return [
'name' => 'Name',
'class' => 'Class',
'senderClass' => 'Sender',
'isStatic' => 'Static',
];
}
public void rules ( ) |
public function rules()
{
return [
[['name', 'class', 'senderClass'], 'string'],
[['isStatic'], 'boolean'],
//[['isStatic'], 'filter', 'filter' => function ($value) {return strlen($value) > 0 ? (bool)$value : $value;}],
[$this->attributes(), 'safe'],
];
}
Returns data provider with filled models. Filter applied if needed.
public \yii\data\ArrayDataProvider search ( $params, $models ) | ||
$params | array |
An array of parameter values indexed by parameter names |
$models | array |
Data to return provider for |
public function search($params, $models)
{
$dataProvider = new ArrayDataProvider([
'allModels' => $models,
'pagination' => false,
'sort' => [
'attributes' => ['time', 'level', 'category', 'message'],
'defaultOrder' => [
'time' => SORT_ASC,
],
],
]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$filter = new Filter();
$this->addCondition($filter, 'isStatic');
$this->addCondition($filter, 'name', true);
$this->addCondition($filter, 'class', true);
$this->addCondition($filter, 'senderClass', true);
$dataProvider->allModels = $filter->filter($models);
return $dataProvider;
}