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]]
+
+
+
+ | Class of not found elements |
+ Element names |
+
+
+
+ [[+nfRows]]
+
+
| Total parse time | [[+total_parse_time]] s |
| Total queries | [[+total_queries]] |
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