Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getErrorsAsString example
try
{
if
(
$this
->
isXmlString
(
$resource
)
)
{
$dom
= XmlUtils::
parse
(
$resource
)
;
}
else
{
$dom
= XmlUtils::
loadFile
(
$resource
)
;
}
}
catch
(
\InvalidArgumentException|XmlParsingException|InvalidXmlException
$e
)
{
throw
new
InvalidResourceException
(
sprintf
(
'Unable to load "%s": ',
$resource
)
.
$e
->
getMessage
(
)
,
$e
->
getCode
(
)
,
$e
)
;
}
if
(
$errors
= XliffUtils::
validateSchema
(
$dom
)
)
{
throw
new
InvalidResourceException
(
sprintf
(
'Invalid resource provided: "%s"; Errors: ',
$resource
)
.XliffUtils::
getErrorsAsString
(
$errors
)
)
;
}
$catalogue
=
new
MessageCatalogue
(
$locale
)
;
$this
->
extract
(
$dom
,
$catalogue
,
$domain
)
;
if
(
is_file
(
$resource
)
&&
class_exists
(
FileResource::
class
)
)
{
$catalogue
->
addResource
(
new
FileResource
(
$resource
)
)
;
}
return
$catalogue
;
}