Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
addThumbnailUrl example
public
function
addUrls
(
EntityLoadedEvent
$event
)
: void
{
/** @var MediaEntity $media */
foreach
(
$event
->
getEntities
(
)
as
$media
)
{
if
(
!
$media
->
hasFile
(
)
||
$media
->
isPrivate
(
)
)
{
continue
;
}
$media
->
setUrl
(
$this
->urlGenerator->
getAbsoluteMediaUrl
(
$media
)
)
;
foreach
(
$media
->
getThumbnails
(
)
??
[
]
as
$thumbnail
)
{
$this
->
addThumbnailUrl
(
$thumbnail
,
$media
)
;
}
}
}
public
function
unserialize
(
EntityLoadedEvent
$event
)
: void
{
/** @var MediaEntity $media */
foreach
(
$event
->
getEntities
(
)
as
$media
)
{
if
(
$media
->
getMediaTypeRaw
(
)
)
{
$media
->
setMediaType
(
unserialize
(
$media
->
getMediaTypeRaw
(
)
)
)
;
}