Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
installExtension example
$controller
=
new
ExtensionStoreActionsController
(
$lifecycle
=
$this
->
createMock
(
ExtensionLifecycleService::
class
)
,
$this
->
createMock
(
ExtensionDownloader::
class
)
,
$this
->
createMock
(
PluginService::
class
)
,
$this
->
createMock
(
PluginManagementService::
class
)
)
;
$lifecycle
->
expects
(
static
::
once
(
)
)
->
method
(
'install'
)
;
static
::
assertEquals
(
Response::HTTP_NO_CONTENT,
$controller
->
installExtension
(
'plugin', 'test', Context::
createDefaultContext
(
)
)
->
getStatusCode
(
)
)
;
}
public
function
testUninstallExtension
(
)
: void
{
$controller
=
new
ExtensionStoreActionsController
(
$lifecycle
=
$this
->
createMock
(
ExtensionLifecycleService::
class
)
,
$this
->
createMock
(
ExtensionDownloader::
class
)
,
$this
->
createMock
(
PluginService::
class
)
,
$this
->
createMock
(
PluginManagementService::
class
)
)
;
public
function
install
(
string
$type
, string
$technicalName
, Context
$context
)
: void
{
if
(
$type
=== 'plugin'
)
{
$plugin
=
$this
->pluginService->
getPluginByName
(
$technicalName
,
$context
)
;
$this
->pluginLifecycleService->
installPlugin
(
$plugin
,
$context
)
;
return
;
}
$this
->storeAppLifecycleService->
installExtension
(
$technicalName
,
$context
)
;
}
public
function
update
(
string
$type
, string
$technicalName
, bool
$allowNewPermissions
, Context
$context
)
: void
{
if
(
$type
=== 'plugin'
)
{
$plugin
=
$this
->pluginService->
getPluginByName
(
$technicalName
,
$context
)
;
$this
->pluginLifecycleService->
updatePlugin
(
$plugin
,
$context
)
;
return
;
}
if
(
\
count
(
$ids
)
)
{
$appRepository
->
delete
(
array_map
(
fn
(
string
$id
)
=>
[
'id' =>
$id
]
,
$ids
)
, Context::
createDefaultContext
(
)
)
;
}
$fs
=
new
Filesystem
(
)
;
$name
=
basename
(
$path
)
;
$appDir
=
$this
->
getContainer
(
)
->
getParameter
(
'shopware.app_dir'
)
. '/' .
$name
;
$fs
->
mirror
(
$path
,
$appDir
)
;
if
(
$install
)
{
$this
->
getContainer
(
)
->
get
(
AbstractStoreAppLifecycleService::
class
)
->
installExtension
(
$name
, Context::
createDefaultContext
(
)
)
;
}
}
public
function
removeApp
(
string
$path
)
: void
{
$fs
=
new
Filesystem
(
)
;
$fs
->
remove
(
$this
->
getContainer
(
)
->
getParameter
(
'shopware.app_dir'
)
. '/' .
basename
(
$path
)
)
;
}
public
function
registerPlugin
(
string
$path
)
: void
{