No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

81 líneas
1.7KB

  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 database queries.
  12. *
  13. * @author Qiang Xue <qiang.xue@gmail.com>
  14. * @author Mark Jebri <mark.github@yandex.ru>
  15. * @since 2.0
  16. */
  17. class Db extends Base
  18. {
  19. /**
  20. * @var string type of the input search value
  21. */
  22. public $type;
  23. /**
  24. * @var integer query attribute input search value
  25. */
  26. public $query;
  27. /**
  28. * @inheritdoc
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['type', 'query'], 'safe'],
  34. ];
  35. }
  36. /**
  37. * @inheritdoc
  38. */
  39. public function attributeLabels()
  40. {
  41. return [
  42. 'type' => 'Type',
  43. 'query' => 'Query',
  44. ];
  45. }
  46. /**
  47. * Returns data provider with filled models. Filter applied if needed.
  48. *
  49. * @param array $models data to return provider for
  50. * @return \yii\data\ArrayDataProvider
  51. */
  52. public function search($models)
  53. {
  54. $dataProvider = new ArrayDataProvider([
  55. 'allModels' => $models,
  56. 'pagination' => false,
  57. 'sort' => [
  58. 'attributes' => ['duration', 'seq', 'type', 'query'],
  59. ],
  60. ]);
  61. if (!$this->validate()) {
  62. return $dataProvider;
  63. }
  64. $filter = new Filter();
  65. $this->addCondition($filter, 'type', true);
  66. $this->addCondition($filter, 'query', true);
  67. $dataProvider->allModels = $filter->filter($models);
  68. return $dataProvider;
  69. }
  70. }