Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
activateExtension example
public
function
activate
(
string
$type
, string
$technicalName
, Context
$context
)
: void
{
if
(
$type
=== 'plugin'
)
{
$plugin
=
$this
->pluginService->
getPluginByName
(
$technicalName
,
$context
)
;
$this
->pluginLifecycleService->
activatePlugin
(
$plugin
,
$context
)
;
return
;
}
$this
->storeAppLifecycleService->
activateExtension
(
$technicalName
,
$context
)
;
}
public
function
deactivate
(
string
$type
, string
$technicalName
, Context
$context
)
: void
{
if
(
$type
=== 'plugin'
)
{
$plugin
=
$this
->pluginService->
getPluginByName
(
$technicalName
,
$context
)
;
$this
->pluginLifecycleService->
deactivatePlugin
(
$plugin
,
$context
)
;
return
;
}
$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
(
'activate'
)
;
static
::
assertEquals
(
Response::HTTP_NO_CONTENT,
$controller
->
activateExtension
(
'plugin', 'test', Context::
createDefaultContext
(
)
)
->
getStatusCode
(
)
)
;
}
public
function
testDeactivateExtension
(
)
: void
{
$controller
=
new
ExtensionStoreActionsController
(
$lifecycle
=
$this
->
createMock
(
ExtensionLifecycleService::
class
)
,
$this
->
createMock
(
ExtensionDownloader::
class
)
,
$this
->
createMock
(
PluginService::
class
)
,
$this
->
createMock
(
PluginManagementService::
class
)
)
;