Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
executeInWorkspace example
$live_node
=
$storage
->
load
(
$node
->
id
(
)
)
;
$this
->
assertEquals
(
'live node 1',
$live_node
->title->value
)
;
$result
=
$storage
->
getQuery
(
)
->
accessCheck
(
FALSE
)
->
condition
(
'title', 'live node 1'
)
->
execute
(
)
;
$this
->
assertEquals
(
[
$live_node
->
getRevisionId
(
)
=>
$node
->
id
(
)
]
,
$result
)
;
// Try the same assertions in the context of the 'stage' workspace.
$this
->workspaceManager->
executeInWorkspace
(
'stage',
function
D
)
use
(
$node
,
$storage
)
{
$this
->
assertEquals
(
'stage',
$this
->workspaceManager->
getActiveWorkspace
(
)
->
id
(
)
)
;
$stage_node
=
$storage
->
load
(
$node
->
id
(
)
)
;
$this
->
assertEquals
(
'stage node 1',
$stage_node
->title->value
)
;
$result
=
$storage
->
getQuery
(
)
->
accessCheck
(
FALSE
)
->
condition
(
'title', 'stage node 1'
)
->
execute
(
)
;
$this
->
assertEquals
(
[
$stage_node
->
getRevisionId
(
)
=>
$stage_node
->
id
(
)
]
,
$result
)
;
}
)
;