You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Profile.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\debug\models\search;
  8. use yii\data\ArrayDataProvider;
  9. use yii\debug\components\search\Filter;
  10. /**
  11. * Search model for current request profiling log.
  12. *
  13. * @author Qiang Xue <qiang.xue@gmail.com>
  14. * @author Mark Jebri <mark.github@yandex.ru>
  15. * @since 2.0
  16. */
  17. class Profile extends Base
  18. {
  19. /**
  20. * @var string method attribute input search value
  21. */
  22. public $category;
  23. /**
  24. * @var integer info attribute input search value
  25. */
  26. public $info;
  27. /**
  28. * @inheritdoc
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['category', 'info'], 'safe'],
  34. ];
  35. }
  36. /**
  37. * @inheritdoc
  38. */
  39. public function attributeLabels()
  40. {
  41. return [
  42. 'category' => 'Category',
  43. 'info' => 'Info',
  44. ];
  45. }
  46. /**
  47. * Returns data provider with filled models. Filter applied if needed.
  48. *
  49. * @param array $params an array of parameter values indexed by parameter names
  50. * @param array $models data to return provider for
  51. * @return \yii\data\ArrayDataProvider
  52. */
  53. public function search($params, $models)
  54. {
  55. $dataProvider = new ArrayDataProvider([
  56. 'allModels' => $models,
  57. 'pagination' => false,
  58. 'sort' => [
  59. 'attributes' => ['category', 'seq', 'duration', 'info'],
  60. 'defaultOrder' => [
  61. 'duration' => SORT_DESC,
  62. ],
  63. ],
  64. ]);
  65. if (!($this->load($params) && $this->validate())) {
  66. return $dataProvider;
  67. }
  68. $filter = new Filter();
  69. $this->addCondition($filter, 'category', true);
  70. $this->addCondition($filter, 'info', true);
  71. $dataProvider->allModels = $filter->filter($models);
  72. return $dataProvider;
  73. }
  74. }