Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
SyncResult example
$writes
->
addEvent
(
...
$deletes
->
getEvents
(
)
->
getElements
(
)
)
;
}
$this
->eventDispatcher->
dispatch
(
$writes
)
;
$ids
=
$this
->
getWrittenEntities
(
$result
->
getWritten
(
)
)
;
$deleted
=
$this
->
getWrittenEntitiesByEvent
(
$deletes
)
;
$notFound
=
$this
->
getWrittenEntities
(
$result
->
getNotFound
(
)
)
;
return
new
SyncResult
(
$ids
,
$notFound
,
$deleted
)
;
}
/** * @param array<string, EntityWriteResult[]> $grouped * * @return array<string, array<int, mixed>> */
private
function
getWrittenEntities
(
array
$grouped
)
: array
{
$mapped
=
[
]
;
->
method
(
'sync'
)
->
willReturnCallback
(
function
D
$operations
)
use
(
$criteria
)
{
static
::
assertCount
(
1,
$operations
)
;
static
::
assertInstanceOf
(
SyncOperation::
class
,
$operations
[
0
]
)
;
$operation
=
$operations
[
0
]
;
static
::
assertSame
(
'delete-mapping',
$operation
->
getKey
(
)
)
;
static
::
assertSame
(
'product',
$operation
->
getEntity
(
)
)
;
static
::
assertSame
(
'delete',
$operation
->
getAction
(
)
)
;
static
::
assertEquals
(
$criteria
,
$operation
->
getCriteria
(
)
)
;
return
new
SyncResult
(
[
]
)
;
}
)
;
$controller
=
new
SyncController
(
$service
,
new
Serializer
(
[
]
,
[
new
JsonEncoder
(
)
]
)
)
;
$controller
->
sync
(
$request
, Context::
createDefaultContext
(
)
)
;
}
}