33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2025-01-01 06:01:46 +00:00

Mitigate error to a note for missed optional node

This commit is contained in:
Denis Ryabov 2021-04-04 14:29:53 +03:00
parent f914e438c5
commit 03f22df7d9
2 changed files with 24 additions and 15 deletions

View File

@ -85,6 +85,7 @@ COM_JEDCHECKER_MANIFEST_TYPE_NOT_ACCEPTED="Extension type '%s' is not accepted b
COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE="Node <%1$s> has unknown attribute '%2$s'" COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE="Node <%1$s> has unknown attribute '%2$s'"
COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN="Node <%s> has unknown child element" COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN="Node <%s> has unknown child element"
COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED="Node <%1$s> doesn't contain required <%2$s> element" COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED="Node <%1$s> doesn't contain required <%2$s> element"
COM_JEDCHECKER_MANIFEST_MISSED_OPTIONAL="Node <%1$s> doesn't contain optional <%2$s> element"
COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND="Node <%1$s> contains multiple <%2$s> elements" COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND="Node <%1$s> contains multiple <%2$s> elements"
COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD="Node <%1$s> contains unknown <%2$s> element" COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD="Node <%1$s> contains unknown <%2$s> element"
COM_JEDCHECKER_MANIFEST_EMPTY_CHILD="Found empty <%s> element" COM_JEDCHECKER_MANIFEST_EMPTY_CHILD="Found empty <%s> element"

View File

@ -289,25 +289,33 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
switch ($mode) switch ($mode)
{ {
case '!': case '!':
$errors =& $this->errors;
break;
case '=':
$errors =& $this->warnings;
break;
default:
continue 2;
}
if ($count === 0) if ($count === 0)
{ {
$errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED', $name, $child); // The node doesn't contain required child element
$this->errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED', $name, $child);
} }
elseif ($count > 1) elseif ($count > 1)
{ {
$errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child); // The node contains multiple child elements when single only is expected
$this->errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child);
} }
unset($errors); break;
case '=':
if ($count === 0)
{
// The node doesn't contain optional child element
$this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_OPTIONAL', $name, $child);
}
elseif ($count > 1)
{
// The node contains multiple child elements when single only is expected
$this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child);
}
break;
}
} }
// 2) check unknown/multiple elements // 2) check unknown/multiple elements