Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getDefaultModule example
/** * {@inheritdoc} */
public
function
generate
(
array
$params
, Context
$context
)
{
$route
=
[
]
;
if
(
\
array_key_exists
(
'_seo',
$params
)
)
{
unset
(
$params
[
'_seo'
]
)
;
}
$module
=
$params
[
$context
->
getModuleKey
(
)
]
??
$this
->dispatcher->
getDefaultModule
(
)
;
$controller
=
$params
[
$context
->
getControllerKey
(
)
]
??
$this
->dispatcher->
getDefaultControllerName
(
)
;
$action
=
$params
[
$context
->
getActionKey
(
)
]
??
$this
->dispatcher->
getDefaultAction
(
)
;
unset
(
$params
[
$context
->
getModuleKey
(
)
]
,
$params
[
$context
->
getControllerKey
(
)
]
,
$params
[
$context
->
getActionKey
(
)
]
)
;
if
(
$module
!==
$this
->dispatcher->
getDefaultModule
(
)
)
{
$route
[
]
=
$module
;
}
return
$this
->
fillDefaults
(
$context
,
$query
)
;
}
/** * Fills up default values for module, controller and action */
private
function
fillDefaults
(
Context
$context
, array
$query
)
: array
{
$defaults
=
[
$context
->
getModuleKey
(
)
=>
$this
->dispatcher->
getDefaultModule
(
)
,
$context
->
getControllerKey
(
)
=>
$this
->dispatcher->
getDefaultControllerName
(
)
,
$context
->
getActionKey
(
)
=>
$this
->dispatcher->
getDefaultAction
(
)
,
]
;
return
array_merge
(
$defaults
,
$query
)
;
}
}