Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
PluginNotAZipFileException example
/** @var UploadedFile|null $file */
$file
=
$request
->files->
get
(
'file'
)
;
if
(
!
$file
)
{
throw
RoutingException::
missingRequestParameter
(
'file'
)
;
}
if
(
$file
->
getMimeType
(
)
!== 'application/zip'
)
{
unlink
(
$file
->
getPathname
(
)
)
;
throw
new
PluginNotAZipFileException
(
(string)
$file
->
getMimeType
(
)
)
;
}
try
{
$this
->pluginManagementService->
uploadPlugin
(
$file
,
$context
)
;
}
catch
(
\Exception
$e
)
{
unlink
(
$file
->
getPathname
(
)
)
;
throw
$e
;
}
return
new
Response
(
'', Response::HTTP_NO_CONTENT
)
;
}