Panel.php 2.51 KB
Newer Older
Qiang Xue committed
1 2 3 4 5 6 7 8 9
<?php
/**
 * @link http://www.yiiframework.com/
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 */

namespace yii\debug;

Qiang Xue committed
10
use Yii;
Qiang Xue committed
11
use yii\base\Component;
12
use yii\helpers\Url;
Qiang Xue committed
13 14

/**
Qiang Xue committed
15 16
 * Panel is a base class for debugger panel classes. It defines how data should be collected,
 * what should be displayed at debug toolbar and on debugger details view.
Alexander Makarov committed
17
 *
18 19 20 21
 * @property string $detail Content that is displayed in debugger detail view. This property is read-only.
 * @property string $name Name of the panel. This property is read-only.
 * @property string $summary Content that is displayed at debug toolbar. This property is read-only.
 * @property string $url URL pointing to panel detail view. This property is read-only.
22
 *
Qiang Xue committed
23 24 25 26 27
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @since 2.0
 */
class Panel extends Component
{
28 29 30 31
    /**
     * @var string panel unique identifier.
     * It is set automatically by the container module.
     */
32
    public $id;
33 34 35
    /**
     * @var string request data set identifier.
     */
36 37 38 39 40
    public $tag;
    /**
     * @var Module
     */
    public $module;
41 42 43
    /**
     * @var mixed data associated with panel
     */
44 45 46 47 48 49 50
    public $data;
    /**
     * @var array array of actions to add to the debug modules default controller.
     * This array will be merged with all other panels actions property.
     * See [[\yii\base\Controller::actions()]] for the format.
     */
    public $actions = [];
Qiang Xue committed
51

52

53 54 55 56 57 58 59
    /**
     * @return string name of the panel
     */
    public function getName()
    {
        return '';
    }
Qiang Xue committed
60

61 62 63 64 65 66 67
    /**
     * @return string content that is displayed at debug toolbar
     */
    public function getSummary()
    {
        return '';
    }
Qiang Xue committed
68

69 70 71 72 73 74 75
    /**
     * @return string content that is displayed in debugger detail view
     */
    public function getDetail()
    {
        return '';
    }
Qiang Xue committed
76

77 78 79 80 81 82 83 84 85 86
    /**
     * Saves data to be later used in debugger detail view.
     * This method is called on every page where debugger is enabled.
     *
     * @return mixed data to be saved
     */
    public function save()
    {
        return null;
    }
Qiang Xue committed
87

88 89 90 91 92 93 94 95 96
    /**
     * Loads data into the panel
     *
     * @param mixed $data
     */
    public function load($data)
    {
        $this->data = $data;
    }
Qiang Xue committed
97

98 99 100 101 102
    /**
     * @return string URL pointing to panel detail view
     */
    public function getUrl()
    {
103
        return Url::toRoute(['/' . $this->module->id . '/default/view',
104 105 106 107
            'panel' => $this->id,
            'tag' => $this->tag,
        ]);
    }
Qiang Xue committed
108
}