Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
uploadPlugin example
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
)
;
}
#[Route(path: '/api/_action/extension/download/{technicalName}', name: 'api.extension.download', methods: ['POST'])]
public
function
downloadExtension
(
string
$technicalName
, Context
$context
)
: Response
{
$this
->filesystem->
remove
(
self::PLUGIN_FASHION_THEME_PATH
)
;
$this
->filesystem->
remove
(
self::PLUGIN_ZIP_FIXTURE_PATH
)
;
$this
->filesystem->
remove
(
$this
->cacheDir
)
;
Kernel::
getConnection
(
)
->
executeStatement
(
'DELETE FROM plugin'
)
;
}
public
function
testUploadPlugin
(
)
: void
{
$pluginFile
=
$this
->
createUploadedFile
(
)
;
$this
->
getPluginManagementService
(
)
->
uploadPlugin
(
$pluginFile
, Context::
createDefaultContext
(
)
)
;
static
::
assertFileExists
(
self::PLUGIN_FASHION_THEME_PATH
)
;
static
::
assertFileExists
(
self::PLUGIN_FASHION_THEME_BASE_CLASS_PATH
)
;
}
public
function
testExtractPluginZip
(
)
: void
{
$this
->
getPluginManagementService
(
)
->
extractPluginZip
(
self::PLUGIN_ZIP_FIXTURE_PATH
)
;
$extractedPlugin
=
$this
->filesystem->
exists
(
self::PLUGIN_FASHION_THEME_PATH
)
;
$extractedPluginBaseClass
=
$this
->filesystem->
exists
(
self::PLUGIN_FASHION_THEME_BASE_CLASS_PATH
)
;