RouterPanel.php 1.8 KB

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\panels;
  8. use Yii;
  9. use yii\debug\models\Router;
  10. use yii\debug\Panel;
  11. use yii\log\Logger;
  12. /**
  13. * RouterPanel provides a panel which displays information about routing process.
  14. *
  15. * @property array $categories Note that the type of this property differs in getter and setter. See
  16. * [[getCategories()]] and [[setCategories()]] for details.
  17. *
  18. * @author Dmitriy Bashkarev <dmitriy@bashkarev.com>
  19. * @since 2.0.8
  20. */
  21. class RouterPanel extends Panel
  22. {
  23. /**
  24. * @var array
  25. */
  26. private $_categories = [
  27. 'yii\web\UrlManager::parseRequest',
  28. 'yii\web\UrlRule::parseRequest',
  29. 'yii\web\CompositeUrlRule::parseRequest',
  30. 'yii\rest\UrlRule::parseRequest'
  31. ];
  32. /**
  33. * @param string|array $values
  34. */
  35. public function setCategories($values)
  36. {
  37. if (!is_array($values)) {
  38. $values = [$values];
  39. }
  40. $this->_categories = array_merge($this->_categories, $values);
  41. }
  42. /**
  43. * Listens categories of the messages.
  44. * @return array
  45. */
  46. public function getCategories()
  47. {
  48. return $this->_categories;
  49. }
  50. /**
  51. * @inheritdoc
  52. */
  53. public function getName()
  54. {
  55. return 'Router';
  56. }
  57. /**
  58. * @inheritdoc
  59. */
  60. public function getDetail()
  61. {
  62. return Yii::$app->view->render('panels/router/detail', ['model' => new Router($this->data)]);
  63. }
  64. /**
  65. * @inheritdoc
  66. */
  67. public function save()
  68. {
  69. $target = $this->module->logTarget;
  70. return [
  71. 'messages' => $target::filterMessages($target->messages, Logger::LEVEL_TRACE, $this->_categories)
  72. ];
  73. }
  74. }