Commit 18be2212 by Alexander Makarov

Refactored debug module, added all missing docs

parent 5fbd4ce7
......@@ -9,6 +9,8 @@ namespace yii\debug;
use yii\web\AssetBundle;
/**
* Debugger asset bundle
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
......
......@@ -72,6 +72,13 @@ class LogTarget extends Target
$this->updateIndexFile($indexFile, $summary);
}
/**
* Updates index file with summary log data
*
* @param string $indexFile path to index file
* @param array $summary summary log data
* @throws \yii\base\InvalidConfigException
*/
private function updateIndexFile($indexFile, $summary)
{
touch($indexFile);
......
......@@ -50,7 +50,9 @@ class Module extends \yii\base\Module
*/
public $historySize = 50;
/**
* @inheritdoc
*/
public function init()
{
parent::init();
......@@ -69,13 +71,16 @@ class Module extends \yii\base\Module
}
}
/**
* @inheritdoc
*/
public function beforeAction($action)
{
Yii::$app->getView()->off(View::EVENT_END_BODY, [$this, 'renderToolbar']);
unset(Yii::$app->getLog()->targets['debug']);
$this->logTarget = null;
if ($this->checkAccess($action)) {
if ($this->checkAccess()) {
return parent::beforeAction($action);
} elseif ($action->id === 'toolbar') {
return false;
......@@ -84,6 +89,11 @@ class Module extends \yii\base\Module
}
}
/**
* Renders mini-toolbar at the end of page body.
*
* @param \yii\base\Event $event
*/
public function renderToolbar($event)
{
if (!$this->checkAccess() || Yii::$app->getRequest()->getIsAjax()) {
......@@ -99,6 +109,10 @@ class Module extends \yii\base\Module
echo '<script>' . $view->renderPhpFile(__DIR__ . '/assets/toolbar.js') . '</script>';
}
/**
* Checks if current user is allowed to access the module
* @return boolean if access is granted
*/
protected function checkAccess()
{
$ip = Yii::$app->getRequest()->getUserIP();
......@@ -111,6 +125,9 @@ class Module extends \yii\base\Module
return false;
}
/**
* @return array default set of panels
*/
protected function corePanels()
{
return [
......
......@@ -73,6 +73,11 @@ class Panel extends Component
return null;
}
/**
* Loads data into the panel
*
* @param mixed $data
*/
public function load($data)
{
$this->data = $data;
......
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\debug\components\search;
use yii\base\Component;
use yii\debug\components\search\matchers\MatcherInterface;
/**
* Provides array filtering capabilities.
*
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
*/
class Filter extends Component
{
/**
* @var array rules for matching filters in the way: [:fieldName => [rule1, rule2,..]]
*/
protected $rules = [];
/**
* Adds rules for filtering data. Match can be partial or exactly.
* Adds data filtering rule.
*
* @param string $name attribute name
* @param \yii\debug\components\search\matches\Base $rule
* @param MatcherInterface $rule
*/
public function addMatch($name, $rule)
public function addMatcher($name, MatcherInterface $rule)
{
if (empty($rule->value) && $rule->value !== 0) {
return;
}
if ($rule->hasValue()) {
$this->rules[$name][] = $rule;
}
}
/**
* Applies filter on given array and returns filtered data.
* Applies filter on a given array and returns filtered data.
*
* @param array $data data to filter
* @return array filtered data
*/
......@@ -36,7 +47,7 @@ class Filter extends Component
$filtered = [];
foreach ($data as $row) {
if ($this->checkFilter($row)) {
if ($this->passesFilter($row)) {
$filtered[] = $row;
}
}
......@@ -45,28 +56,25 @@ class Filter extends Component
}
/**
* Check if the given data satisfies filters.
* @param array $row
* Checks if the given data satisfies filters.
*
* @param array $row data
* @return boolean if data passed filtering
*/
public function checkFilter(array $row)
private function passesFilter(array $row)
{
$matched = true;
foreach ($row as $name => $value) {
if (isset($this->rules[$name])) {
#check all rules for given attribute
// check all rules for a given attribute
foreach ($this->rules[$name] as $rule) {
if (!$rule->check($value)) {
$matched = false;
/** @var MatcherInterface $rule */
if (!$rule->match($value)) {
return false;
}
}
}
}
return $matched;
return true;
}
}
......@@ -5,22 +5,36 @@
* @license http://www.yiiframework.com/license/
*/
namespace yii\debug\components\search\matches;
namespace yii\debug\components\search\matchers;
use yii\base\Component;
/**
* Base mathcer class for all matchers that will be used with filter.
* Base class for matchers that are used in a filter.
*
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
*/
abstract class Base extends Component implements MatcherInterface
{
/**
* @var mixed base value to check
*/
protected $baseValue;
/**
* @var mixed current value to check for the matcher
* @inheritdoc
*/
public $value;
public function setValue($value)
{
$this->baseValue = $value;
}
/**
* @inheritdoc
*/
public function hasValue()
{
return !empty($this->baseValue) || $this->baseValue === 0;
}
}
......@@ -5,23 +5,21 @@
* @license http://www.yiiframework.com/license/
*/
namespace yii\debug\components\search\matches;
namespace yii\debug\components\search\matchers;
/**
* Checks if the given value is greater than the base one.
*
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
*/
class Greater extends Base
class GreaterThan extends Base
{
/**
* Checks if the given value is the same as base one or has partial match with base one.
* @param mixed $value
* @inheritdoc
*/
public function check($value)
public function match($value)
{
return ($value > $this->value);
return ($value > $this->baseValue);
}
}
......@@ -5,23 +5,21 @@
* @license http://www.yiiframework.com/license/
*/
namespace yii\debug\components\search\matches;
namespace yii\debug\components\search\matchers;
/**
* Checks if the given value is lower than the base one.
*
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
*/
class Lower extends Base
class LowerThan extends Base
{
/**
* Checks if the given value is the same as base one or has partial match with base one.
* @param mixed $value
* @inheritdoc
*/
public function check($value)
public function match($value)
{
return ($value < $this->value);
return ($value < $this->baseValue);
}
}
......@@ -5,21 +5,35 @@
* @license http://www.yiiframework.com/license/
*/
namespace yii\debug\components\search\matches;
namespace yii\debug\components\search\matchers;
/**
* MatcherInterface is the interface that should be implemented by all matchers that will be used in filter.
* MatcherInterface should be implemented by all matchers that are used in a filter.
*
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
*/
interface MatcherInterface
{
/**
* Checks if the value passed matches base value.
*
* @param mixed $value value to be matched
* @return boolean if there is a match
*/
public function match($value);
/**
* Check if the value is correct according current matcher.
* Sets base value to match against
*
* @param mixed $value
*/
public function check($value);
public function setValue($value);
/**
* Checks if base value is set
*
* @return boolean if base value is set
*/
public function hasValue();
}
......@@ -5,32 +5,30 @@
* @license http://www.yiiframework.com/license/
*/
namespace yii\debug\components\search\matches;
namespace yii\debug\components\search\matchers;
/**
* Checks if the given value is exactly or partially same as the base one.
*
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
*/
class Exact extends Base
class SameAs extends Base
{
/**
* @var boolean if current matcher should consider partial match of given value.
* @var boolean if partial match should be used.
*/
public $partial = false;
/**
* Checks if the given value is the same as base one or has partial match with base one.
* @param mixed $value
* @inheritdoc
*/
public function check($value)
public function match($value)
{
if (!$this->partial) {
return (mb_strtolower($this->value, 'utf8') == mb_strtolower($value, 'utf8'));
return (mb_strtolower($this->baseValue, 'utf8') == mb_strtolower($value, 'utf8'));
} else {
return (mb_strpos(mb_strtolower($value, 'utf8'), mb_strtolower($this->value,'utf8')) !== false);
return (mb_strpos(mb_strtolower($value, 'utf8'), mb_strtolower($this->baseValue, 'utf8')) !== false);
}
}
}
......@@ -13,11 +13,16 @@ use yii\web\NotFoundHttpException;
use yii\debug\models\search\Debug;
/**
* Debugger controller
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class DefaultController extends Controller
{
/**
* @inheritdoc
*/
public $layout = 'main';
/**
* @var \yii\debug\Module
......@@ -28,6 +33,9 @@ class DefaultController extends Controller
*/
public $summary;
/**
* @inheritdoc
*/
public function actions()
{
$actions = [];
......
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\debug\models\search;
use yii\base\Model;
use yii\debug\components\search\Filter;
use yii\debug\components\search\matches;
use yii\debug\components\search\matchers;
/**
* Base search model
*
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
*/
class Base extends Model
{
/**
* @param Filter $filter
* @param string $attribute
* @param boolean $partial
* Adds filtering condition for a given attribute
*
* @param Filter $filter filter instance
* @param string $attribute attribute to filter
* @param boolean $partial if partial match should be used
*/
public function addCondition($filter, $attribute, $partial = false)
public function addCondition(Filter $filter, $attribute, $partial = false)
{
$value = $this->$attribute;
if (mb_strpos($value, '>') !== false) {
$value = intval(str_replace('>', '', $value));
$filter->addMatch($attribute, new matches\Greater(['value' => $value]));
$filter->addMatcher($attribute, new matchers\GreaterThan(['value' => $value]));
} elseif (mb_strpos($value, '<') !== false) {
$value = intval(str_replace('<', '', $value));
$filter->addMatch($attribute, new matches\Lower(['value' => $value]));
$filter->addMatcher($attribute, new matchers\LowerThan(['value' => $value]));
} else {
$filter->addMatch($attribute, new matches\Exact(['value' => $value, 'partial' => $partial]));
$filter->addMatcher($attribute, new matchers\SameAs(['value' => $value, 'partial' => $partial]));
}
}
}
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\debug\models\search;
......@@ -6,13 +11,16 @@ use yii\data\ArrayDataProvider;
use yii\debug\components\search\Filter;
/**
* Db represents the model behind the search form about current request database queries.
* Search model for current request database queries.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
*/
class Db extends Base
{
/**
* @var string type attribute input search value
* @var string type of the input search value
*/
public $type;
......@@ -21,6 +29,9 @@ class Db extends Base
*/
public $query;
/**
* @inheritdoc
*/
public function rules()
{
return [
......@@ -41,8 +52,9 @@ class Db extends Base
/**
* Returns data provider with filled models. Filter applied if needed.
* @param array $params
* @param array $models
*
* @param array $params an array of parameter values indexed by parameter names
* @param array $models data to return provider for
* @return \yii\data\ArrayDataProvider
*/
public function search($params, $models)
......@@ -69,5 +81,4 @@ class Db extends Base
return $dataProvider;
}
}
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\debug\models\search;
......@@ -6,7 +11,11 @@ use yii\data\ArrayDataProvider;
use yii\debug\components\search\Filter;
/**
* Debug represents the model behind the search form about requests manifest data.
* Search model for requests manifest data.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
*/
class Debug extends Base
{
......@@ -51,6 +60,9 @@ class Debug extends Base
*/
public $criticalCodes = [400, 404, 500];
/**
* @inheritdoc
*/
public function rules()
{
return [
......@@ -76,8 +88,8 @@ class Debug extends Base
/**
* Returns data provider with filled models. Filter applied if needed.
* @param array $params
* @param array $models
* @param array $params an array of parameter values indexed by parameter names
* @param array $models data to return provider for
* @return \yii\data\ArrayDataProvider
*/
public function search($params, $models)
......@@ -110,13 +122,13 @@ class Debug extends Base
}
/**
* Checks if the code is critical: 400 or greater, 500 or greater.
* Checks if code is critical.
*
* @param integer $code
* @return bool
* @return boolean
*/
public function isCodeCritical($code)
{
return in_array($code, $this->criticalCodes);
}
}
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\debug\models\search;
......@@ -6,11 +11,14 @@ use yii\data\ArrayDataProvider;
use yii\debug\components\search\Filter;
/**
* Log represents the model behind the search form about current request log.
* Search model for current request log.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
*/
class Log extends Base
{
/**
* @var string ip attribute input search value
*/
......@@ -26,6 +34,9 @@ class Log extends Base
*/
public $message;
/**
* @inheritdoc
*/
public function rules()
{
return [
......@@ -47,8 +58,9 @@ class Log extends Base
/**
* Returns data provider with filled models. Filter applied if needed.
* @param array $params
* @param array $models
*
* @param array $params an array of parameter values indexed by parameter names
* @param array $models data to return provider for
* @return \yii\data\ArrayDataProvider
*/
public function search($params, $models)
......@@ -73,5 +85,4 @@ class Log extends Base
return $dataProvider;
}
}
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\debug\models\search;
......@@ -6,11 +11,14 @@ use yii\data\ArrayDataProvider;
use yii\debug\components\search\Filter;
/**
* Profile represents the model behind the search form about current request profiling log.
* Search model for current request profiling log.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
*/
class Profile extends Base
{
/**
* @var string method attribute input search value
*/
......@@ -21,6 +29,9 @@ class Profile extends Base
*/
public $info;
/**
* @inheritdoc
*/
public function rules()
{
return [
......@@ -41,8 +52,9 @@ class Profile extends Base
/**
* Returns data provider with filled models. Filter applied if needed.
* @param array $params
* @param array $models
*
* @param array $params an array of parameter values indexed by parameter names
* @param array $models data to return provider for
* @return \yii\data\ArrayDataProvider
*/
public function search($params, $models)
......@@ -69,5 +81,4 @@ class Profile extends Base
return $dataProvider;
}
}
......@@ -18,26 +18,45 @@ use yii\debug\Panel;
*/
class ConfigPanel extends Panel
{
/**
* @inheritdoc
*/
public function getName()
{
return 'Configuration';
}
/**
* Returns Yii logo ready to use in `<img src="`
*
* @return string base64 representation of the image
*/
public static function getYiiLogo()
{
return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAeCAYAAADQBxWhAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ft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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAT9/f3+////AQQEBAEAAAABBAQE/f0BAQAABQcASiMNAN3g5wAbDQQADAf/AOgNAXosEgkMAQgAsA4GAe4SEAUA/P8BAAQBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAP//vNz1LVdvDhUAAAAASUVORK5CYII=';
}
/**
* @inheritdoc
*/
public function getSummary()
{
return Yii::$app->view->render('panels/config/summary', ['panel' => $this]);
}
/**
* @inheritdoc
*/
public function getDetail()
{
return Yii::$app->view->render('panels/config/detail', ['panel' => $this]);
}
/**
* Returns data about extensions
*
* @return array
*/
public function getExtensions()
{
$data = [];
......@@ -47,6 +66,9 @@ class ConfigPanel extends Panel
return $data;
}
/**
* @inheritdoc
*/
public function save()
{
return [
......
......@@ -20,7 +20,6 @@ use yii\debug\models\search\Db;
*/
class DbPanel extends Panel
{
/**
* @var array db queries info extracted to array as models, to use with data provider.
*/
......@@ -31,11 +30,17 @@ class DbPanel extends Panel
*/
private $_timings;
/**
* @inheritdoc
*/
public function getName()
{
return 'Database';
}
/**
* @inheritdoc
*/
public function getSummary()
{
$timings = $this->calculateTimings();
......@@ -50,6 +55,9 @@ class DbPanel extends Panel
]);
}
/**
* @inheritdoc
*/
public function getDetail()
{
$searchModel = new Db();
......@@ -63,7 +71,8 @@ class DbPanel extends Panel
}
/**
* Calculates given request profile messages timings.
* Calculates given request profile timings.
*
* @return array timings [token, category, timestamp, traces, nesting level, elapsed time]
*/
protected function calculateTimings()
......@@ -74,6 +83,9 @@ class DbPanel extends Panel
return $this->_timings;
}
/**
* @inheritdoc
*/
public function save()
{
$target = $this->module->logTarget;
......@@ -82,7 +94,8 @@ class DbPanel extends Panel
}
/**
* Returns total queries time.
* Returns total query time.
*
* @param array $timings
* @return integer total time
*/
......@@ -98,8 +111,8 @@ class DbPanel extends Panel
}
/**
* Returns array of models that represents logs of the current request. Can be used with data providers,
* like yii\data\ArrayDataProvider.
* Returns an array of models that represents logs of the current request.
* Can be used with data providers such as \yii\data\ArrayDataProvider.
* @return array models
*/
protected function getModels()
......@@ -110,7 +123,7 @@ class DbPanel extends Panel
foreach($timings as $seq => $dbTiming) {
$this->_models[] = [
'type' => $this->detectQueryType($dbTiming['info']),
'type' => $this->getQueryType($dbTiming['info']),
'query' => $dbTiming['info'],
'duration' => ($dbTiming['duration'] * 1000), // in milliseconds
'trace' => $dbTiming['trace'],
......@@ -123,16 +136,15 @@ class DbPanel extends Panel
}
/**
* Detects databse timing type. Detecting is produced through simple parsing to the first space|tab|new row.
* First word before space is timing type. If there is no such words, timing will have empty type.
* Returns databse query type.
*
* @param string $timing timing procedure string
* @return string query type select|insert|delete|etc
* @return string query type such as select, insert, delete, etc.
*/
protected function detectQueryType($timing)
protected function getQueryType($timing)
{
$timing = ltrim($timing);
preg_match('/^([a-zA-z]*)/', $timing, $matches);
return count($matches) ? $matches[0] : '';
}
}
......@@ -20,22 +20,30 @@ use yii\debug\models\search\Log;
*/
class LogPanel extends Panel
{
/**
* @var array log messages extracted to array as models, to use with data provider.
*/
private $_models;
/**
* @inheritdoc
*/
public function getName()
{
return 'Logs';
}
/**
* @inheritdoc
*/
public function getSummary()
{
return Yii::$app->view->render('panels/log/summary', ['data' => $this->data, 'panel' => $this]);
}
/**
* @inheritdoc
*/
public function getDetail()
{
$searchModel = new Log();
......@@ -48,6 +56,9 @@ class LogPanel extends Panel
]);
}
/**
* @inheritdoc
*/
public function save()
{
$target = $this->module->logTarget;
......@@ -56,9 +67,10 @@ class LogPanel extends Panel
}
/**
* Returns array of models that represents logs of the current request. Can be used with data providers,
* like yii\data\ArrayDataProvider.
* @param boolean $refresh if needed to build models from log messages and refresh them.
* Returns an array of models that represents logs of the current request.
* Can be used with data providers, such as \yii\data\ArrayDataProvider.
*
* @param boolean $refresh if need to build models from log messages and refresh them.
* @return array models
*/
protected function getModels($refresh = false)
......@@ -78,5 +90,4 @@ class LogPanel extends Panel
}
return $this->_models;
}
}
......@@ -25,11 +25,17 @@ class ProfilingPanel extends Panel
*/
private $_models;
/**
* @inheritdoc
*/
public function getName()
{
return 'Profiling';
}
/**
* @inheritdoc
*/
public function getSummary()
{
return Yii::$app->view->render('panels/profile/summary', [
......@@ -39,6 +45,9 @@ class ProfilingPanel extends Panel
]);
}
/**
* @inheritdoc
*/
public function getDetail()
{
$searchModel = new Profile();
......@@ -53,6 +62,9 @@ class ProfilingPanel extends Panel
]);
}
/**
* @inheritdoc
*/
public function save()
{
$target = $this->module->logTarget;
......@@ -65,7 +77,7 @@ class ProfilingPanel extends Panel
}
/**
* Returns array of profiling models that can be used in data provider.
* Returns array of profiling models that can be used in a data provider.
* @return array models
*/
protected function getModels()
......@@ -87,5 +99,4 @@ class ProfilingPanel extends Panel
}
return $this->_models;
}
}
......@@ -19,21 +19,33 @@ use yii\debug\Panel;
*/
class RequestPanel extends Panel
{
/**
* @inheritdoc
*/
public function getName()
{
return 'Request';
}
/**
* @inheritdoc
*/
public function getSummary()
{
return Yii::$app->view->render('panels/request/summary', ['panel' => $this]);
}
/**
* @inheritdoc
*/
public function getDetail()
{
return Yii::$app->view->render('panels/request/detail', ['panel' => $this]);
}
/**
* @inheritdoc
*/
public function save()
{
$headers = Yii::$app->getRequest()->getHeaders();
......@@ -96,5 +108,4 @@ class RequestPanel extends Panel
'SESSION' => empty($_SESSION) ? [] : $_SESSION,
];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment