Class yii\debug\panels\TimelinePanel

Inheritanceyii\debug\panels\TimelinePanel » yii\debug\Panel » yii\base\Component
Available since extension's version2.0.7
Source Code https://github.com/yiisoft/yii2-debug/blob/master/src/panels/TimelinePanel.php

Debugger panel that collects and displays timeline data.

Public Properties

Hide inherited properties

Property Type Description Defined By
$actions array Array of actions to add to the debug modules default controller. yii\debug\Panel
$colors array yii\debug\panels\TimelinePanel
$data mixed Data associated with panel yii\debug\Panel
$detail string Content that is displayed in debugger detail view. yii\debug\Panel
$duration float This property is read-only. yii\debug\panels\TimelinePanel
$error yii\debug\FlattenException|null Error while saving the panel yii\debug\Panel
$id string Panel unique identifier. yii\debug\Panel
$module yii\debug\Module yii\debug\Panel
$name string Name of the panel. yii\debug\Panel
$start float This property is read-only. yii\debug\panels\TimelinePanel
$summary string Content that is displayed at debug toolbar. yii\debug\Panel
$svgOptions array yii\debug\panels\TimelinePanel
$tag string Request data set identifier. yii\debug\Panel
$url string URL pointing to panel detail view. yii\debug\Panel

Protected Properties

Hide inherited properties

Property Type Description Defined By

Public Methods

Hide inherited methods

Method Description Defined By
getColors() Color indicators item profile, key: percentages of time request, value: hex color yii\debug\panels\TimelinePanel
getDetail() yii\debug\panels\TimelinePanel
getDuration() Request duration, milliseconds yii\debug\panels\TimelinePanel
getError() yii\debug\Panel
getMemory() Memory peak in request, bytes. (obtained by memory_get_peak_usage()) yii\debug\panels\TimelinePanel
getName() yii\debug\panels\TimelinePanel
getStart() Start request, timestamp (obtained by microtime(true)) yii\debug\panels\TimelinePanel
getSummary() yii\debug\Panel
getSvg() yii\debug\panels\TimelinePanel
getSvgOptions() yii\debug\panels\TimelinePanel
getTraceLine() Returns a trace line yii\debug\Panel
getUrl() yii\debug\Panel
hasError() yii\debug\Panel
init() yii\debug\panels\TimelinePanel
isEnabled() Checks whether this panel is enabled. yii\debug\Panel
load() Loads data into the panel yii\debug\panels\TimelinePanel
save() Saves data to be later used in debugger detail view. yii\debug\panels\TimelinePanel
setColors() Sets color indicators. yii\debug\panels\TimelinePanel
setError() yii\debug\Panel
setSvgOptions() yii\debug\panels\TimelinePanel

Protected Methods

Hide inherited methods

Method Description Defined By
getModels() Returns an array of models that represents logs of the current request. yii\debug\panels\TimelinePanel

Property Details

Hide inherited properties

$colors public property
public array $colors null
$duration public property

This property is read-only.

public float $duration null
$start public property

This property is read-only.

public float $start null
$svgOptions public property
public array $svgOptions null

Method Details

Hide inherited methods

getColors() public method

Color indicators item profile, key: percentages of time request, value: hex color

public array getColors ( )

                public function getColors()
{
    return $this->_colors;
}

            
getDetail() public method

public string getDetail ( )
return string

Content that is displayed in debugger detail view

                public function getDetail()
{
    $searchModel = new Search();
    $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams(), $this);
    return Yii::$app->view->render('panels/timeline/detail', [
        'panel' => $this,
        'dataProvider' => $dataProvider,
        'searchModel' => $searchModel,
    ]);
}

            
getDuration() public method

Request duration, milliseconds

public float getDuration ( )

                public function getDuration()
{
    return $this->_duration;
}

            
getError() public method (available since version 2.0.10)
public yii\debug\FlattenException|null getError ( )

                public function getError()
{
    return $this->error;
}

            
getMemory() public method (available since version 2.0.8)

Memory peak in request, bytes. (obtained by memory_get_peak_usage())

public integer getMemory ( )

                public function getMemory()
{
    return $this->_memory;
}

            
getModels() protected method

Returns an array of models that represents logs of the current request.

Can be used with data providers, such as \yii\data\ArrayDataProvider.

protected array getModels ( $refresh false )
$refresh boolean

If need to build models from log messages and refresh them.

return array

Models

                protected function getModels($refresh = false)
{
    if ($this->_models === null || $refresh) {
        $this->_models = [];
        if (isset($this->module->panels['profiling']->data['messages'])) {
            $this->_models = Yii::getLogger()->calculateTimings($this->module->panels['profiling']->data['messages']);
        }
    }
    return $this->_models;
}

            
getName() public method

public string getName ( )
return string

Name of the panel

                public function getName()
{
    return 'Timeline';
}

            
getStart() public method

Start request, timestamp (obtained by microtime(true))

public float getStart ( )

                public function getStart()
{
    return $this->_start;
}

            
getSummary() public method
public string getSummary ( )
return string

Content that is displayed at debug toolbar

                public function getSummary()
{
    return '';
}

            
getSvg() public method (available since version 2.0.8)

public yii\debug\models\timeline\Svg getSvg ( )

                public function getSvg()
{
    if ($this->_svg === null) {
        $this->_svg = Yii::createObject($this->_svgOptions,[$this]);
    }
    return $this->_svg;
}

            
getSvgOptions() public method

public array getSvgOptions ( )

                public function getSvgOptions()
{
    return $this->_svgOptions;
}

            
getTraceLine() public method (available since version 2.0.7)

Defined in: yii\debug\Panel::getTraceLine()

Returns a trace line

public string getTraceLine ( $options )
$options array

The array with trace

return string

The trace line

                public function getTraceLine($options)
{
    if (!isset($options['text'])) {
        $options['text'] = "{$options['file']}:{$options['line']}";
    }
    $traceLine = $this->module->traceLine;
    if ($traceLine === false) {
        return $options['text'];
    }
    $options['file'] = str_replace('\\', '/', $options['file']);
    $rawLink = $traceLine instanceof \Closure ? $traceLine($options, $this) : $traceLine;
    return strtr($rawLink, ['{file}' => $options['file'], '{line}' => $options['line'], '{text}' => $options['text']]);
}

            
getUrl() public method
public string getUrl ( $additionalParams null )
$additionalParams null|array

Optional additional parameters to add to the route

return string

URL pointing to panel detail view

                public function getUrl($additionalParams = null)
{
    $route = [
        '/' . $this->module->id . '/default/view',
        'panel' => $this->id,
        'tag' => $this->tag,
    ];
    if (is_array($additionalParams)){
        $route = ArrayHelper::merge($route, $additionalParams);
    }
    return Url::toRoute($route);
}

            
hasError() public method (available since version 2.0.10)
public boolean hasError ( )

                public function hasError()
{
    return $this->error !== null;
}

            
init() public method

public void init ( )

                public function init()
{
    if (!isset($this->module->panels['profiling'])) {
        throw new InvalidConfigException('Unable to determine the profiling panel');
    }
    parent::init();
}

            
isEnabled() public method (available since version 2.0.10)

Defined in: yii\debug\Panel::isEnabled()

Checks whether this panel is enabled.

public boolean isEnabled ( )
return boolean

Whether this panel is enabled.

                public function isEnabled()
{
    return true;
}

            
load() public method

Loads data into the panel

public void load ( $data )
$data mixed

                public function load($data)
{
    if (!isset($data['start']) || empty($data['start'])) {
        throw new \RuntimeException('Unable to determine request start time');
    }
    $this->_start = $data['start'] * 1000;
    if (!isset($data['end']) || empty($data['end'])) {
        throw new \RuntimeException('Unable to determine request end time');
    }
    $this->_end = $data['end'] * 1000;
    if (isset($this->module->panels['profiling']->data['time'])) {
        $this->_duration = $this->module->panels['profiling']->data['time'] * 1000;
    } else {
        $this->_duration = $this->_end - $this->_start;
    }
    if ($this->_duration <= 0) {
        throw new \RuntimeException('Duration cannot be zero');
    }
    if (!isset($data['memory']) || empty($data['memory'])) {
        throw new \RuntimeException('Unable to determine used memory in request');
    }
    $this->_memory = $data['memory'];
}

            
save() public method

Saves data to be later used in debugger detail view.

This method is called on every page where debugger is enabled.

public mixed save ( )
return mixed

Data to be saved

                public function save()
{
    return [
        'start' => YII_BEGIN_TIME,
        'end' => microtime(true),
        'memory' => memory_get_peak_usage(),
    ];
}

            
setColors() public method

Sets color indicators.

key: percentages of time request, value: hex color

public void setColors ( $colors )
$colors array

                public function setColors($colors)
{
    krsort($colors);
    $this->_colors = $colors;
}

            
setError() public method (available since version 2.0.10)
public void setError ( yii\debug\FlattenException $error )
$error yii\debug\FlattenException

                public function setError(FlattenException $error)
{
    $this->error = $error;
}

            
setSvgOptions() public method

public void setSvgOptions ( $options )
$options array

                public function setSvgOptions($options)
{
    if ($this->_svg !== null) {
        $this->_svg = null;
    }
    $this->_svgOptions = array_merge($this->_svgOptions, $options);
}