Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
locateName example
private
function
extractEmotionArchive
(
$filePath
,
$extractPath
)
{
$zip
=
new
ZipArchive
(
)
;
if
(
$zip
->
open
(
$filePath
)
!== true
)
{
throw
new
EmotionImportException
(
sprintf
(
'Could not open zip file "%s"!',
$filePath
)
)
;
}
if
(
$zip
->
locateName
(
'emotion.json'
)
=== false
)
{
throw
new
EmotionImportException
(
sprintf
(
'Missing emotion.json in %s!',
$filePath
)
)
;
}
if
(
$zip
->
extractTo
(
$extractPath
)
!== true
)
{
throw
new
EmotionImportException
(
sprintf
(
'Could not extract zip file %s to %s!',
$filePath
,
$extractPath
)
)
;
}
$zip
->
close
(
)
;
$this
->filesystem->
remove
(
$filePath
)
;
return
json_decode
(
file_get_contents
(
$extractPath
. '/emotion.json'
)
, true
)
;
}