Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
XmlValidationError example
class
XmlValidator
implements
ValidatorInterface
{
public
function
validate
(
ProductExportEntity
$productExportEntity
, string
$productExportContent
, ErrorCollection
$errors
)
: void
{
if
(
$productExportEntity
->
getFileFormat
(
)
!== ProductExportEntity::FILE_FORMAT_XML
)
{
return
;
}
$backup_errors
=
libxml_use_internal_errors
(
true
)
;
if
(
!
simplexml_load_string
(
$productExportContent
)
)
{
$errors
->
add
(
new
XmlValidationError
(
$productExportEntity
->
getId
(
)
,
libxml_get_errors
(
)
)
)
;
}
libxml_use_internal_errors
(
$backup_errors
)
;
}
}