Panel.php 2.27 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 12 13
use yii\base\Component;

/**
Qiang Xue committed
14 15
 * 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
16
 *
17 18 19 20
 * @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.
21
 *
Qiang Xue committed
22 23 24 25 26
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @since 2.0
 */
class Panel extends Component
{
27 28 29 30 31 32 33 34 35 36 37 38 39
    public $id;
    public $tag;
    /**
     * @var Module
     */
    public $module;
    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
40

41 42 43 44 45 46 47
    /**
     * @return string name of the panel
     */
    public function getName()
    {
        return '';
    }
Qiang Xue committed
48

49 50 51 52 53 54 55
    /**
     * @return string content that is displayed at debug toolbar
     */
    public function getSummary()
    {
        return '';
    }
Qiang Xue committed
56

57 58 59 60 61 62 63
    /**
     * @return string content that is displayed in debugger detail view
     */
    public function getDetail()
    {
        return '';
    }
Qiang Xue committed
64

65 66 67 68 69 70 71 72 73 74
    /**
     * 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
75

76 77 78 79 80 81 82 83 84
    /**
     * Loads data into the panel
     *
     * @param mixed $data
     */
    public function load($data)
    {
        $this->data = $data;
    }
Qiang Xue committed
85

86 87 88 89 90 91 92 93 94 95
    /**
     * @return string URL pointing to panel detail view
     */
    public function getUrl()
    {
        return Yii::$app->getUrlManager()->createUrl([$this->module->id . '/default/view',
            'panel' => $this->id,
            'tag' => $this->tag,
        ]);
    }
Qiang Xue committed
96
}