From dd4152a12fd524603f6b756dde664dbb500842fe Mon Sep 17 00:00:00 2001 From: mvoevodskiy Date: Fri, 29 Apr 2016 23:29:26 +0300 Subject: [PATCH] Added logging for not found element at OnElementNotFound event --- _build/data/transport.plugins.php | 1 + .../components/debugparser/docs/changelog.txt | 3 +++ .../elements/plugins/plugin.debugparser.php | 5 +++++ .../templates/template.report.nfrow.tpl | 4 ++++ .../templates/template.report.outer.tpl | 11 +++++++++++ .../debugparser/model/debugparser.class.php | 19 +++++++++++++++++++ .../model/debugpdoparser.class.php | 4 ++++ 7 files changed, 47 insertions(+) create mode 100644 core/components/debugparser/elements/templates/template.report.nfrow.tpl diff --git a/_build/data/transport.plugins.php b/_build/data/transport.plugins.php index d6b5adf..524293f 100644 --- a/_build/data/transport.plugins.php +++ b/_build/data/transport.plugins.php @@ -11,6 +11,7 @@ 'OnWebPagePrerender' => array(), 'OnWebPageInit' => array(), 'OnLoadWebPageCache' => array(), + 'OnElementNotFound' => array(), ) ) ); diff --git a/core/components/debugparser/docs/changelog.txt b/core/components/debugparser/docs/changelog.txt index 8e92b62..bc37f46 100644 --- a/core/components/debugparser/docs/changelog.txt +++ b/core/components/debugparser/docs/changelog.txt @@ -1,5 +1,8 @@ Changelog for debugParser. +============== +- Added logging for not found element at OnElementNotFound event + 1.1.0 pl ============== - Added support of pdoParser with Fenom syntax. diff --git a/core/components/debugparser/elements/plugins/plugin.debugparser.php b/core/components/debugparser/elements/plugins/plugin.debugparser.php index 191196b..c300c8e 100644 --- a/core/components/debugparser/elements/plugins/plugin.debugparser.php +++ b/core/components/debugparser/elements/plugins/plugin.debugparser.php @@ -31,4 +31,9 @@ $modx->parser->generateReport(); } break; + + case 'OnElementNotFound': + if (method_exists($modx->parser, 'addNFElement')) { + $modx->parser->addNFElement($class, $name); + } } \ No newline at end of file diff --git a/core/components/debugparser/elements/templates/template.report.nfrow.tpl b/core/components/debugparser/elements/templates/template.report.nfrow.tpl new file mode 100644 index 0000000..c0292de --- /dev/null +++ b/core/components/debugparser/elements/templates/template.report.nfrow.tpl @@ -0,0 +1,4 @@ + + [[+class]] + [[+elements]] + \ No newline at end of file diff --git a/core/components/debugparser/elements/templates/template.report.outer.tpl b/core/components/debugparser/elements/templates/template.report.outer.tpl index 13a0254..0c97a41 100644 --- a/core/components/debugparser/elements/templates/template.report.outer.tpl +++ b/core/components/debugparser/elements/templates/template.report.outer.tpl @@ -48,6 +48,17 @@ [[+rows]] + + + + + + + + + [[+nfRows]] +
Class of not found elementsElement names
+ diff --git a/core/components/debugparser/model/debugparser.class.php b/core/components/debugparser/model/debugparser.class.php index 9cb36f4..ddce348 100644 --- a/core/components/debugparser/model/debugparser.class.php +++ b/core/components/debugparser/model/debugparser.class.php @@ -2,6 +2,7 @@ class debugParser extends modParser { public $tags = array(); + public $nfElements = array(); public $from_cache = false; /** @var modParser $parser */ protected $parser = null; @@ -75,6 +76,7 @@ public function generateReport() { // Get templates $tplOuter = file_get_contents(MODX_CORE_PATH . 'components/debugparser/elements/templates/template.report.outer.tpl'); $tpl = file_get_contents(MODX_CORE_PATH . 'components/debugparser/elements/templates/template.report.row.tpl'); + $tplNF = file_get_contents(MODX_CORE_PATH . 'components/debugparser/elements/templates/template.report.nfrow.tpl'); $idx = 1; @@ -93,6 +95,14 @@ public function generateReport() { } } + $data['nf'] = ''; + if (!empty($this->nfElements)) { + foreach ($this->nfElements as $class => $elements) { + $pls = $this->makePlaceholders(array('class' => $class, 'elements' => implode(', ', $elements))); + $data['nfRows'] .= str_replace($pls['pl'], $pls['vl'], $tplNF); + } + } + /** @var modProcessorResponse $response */ $response = $this->modx->runProcessor('system/info'); if (!$response->isError()) { @@ -171,6 +181,15 @@ public function clearCache($context = null) { } } + public function addNFElement($class, $name) { + if (!isset($this->nfElements[$class])) { + $this->nfElements[$class] = array(); + } + if (!in_array($name, $this->nfElements[$class])) { + $this->nfElements[$class][] = $name; + } + } + /** * /manager/controllers/default/system/info.class.php * diff --git a/core/components/debugparser/model/debugpdoparser.class.php b/core/components/debugparser/model/debugpdoparser.class.php index 282483d..6904438 100644 --- a/core/components/debugparser/model/debugpdoparser.class.php +++ b/core/components/debugparser/model/debugpdoparser.class.php @@ -82,4 +82,8 @@ public function clearCache($context = null) { $this->parser->clearCache($context); } + public function addNFElement($class, $name) { + $this->parser->addNFElement($class, $name); + } + } \ No newline at end of file
Total parse time[[+total_parse_time]] s
Total queries[[+total_queries]]