Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
generatePhysicalFilename example
private
function
assertCacheBusterGenerator
(
PathnameStrategyInterface
$strategy
)
: void
{
static
::
assertNull
(
$strategy
->
generatePathCacheBuster
(
$this
->
getMediaWithManufacturer
(
)
)
)
;
static
::
assertSame
(
'1293894181',
$strategy
->
generatePathCacheBuster
(
$this
->
getPngWithoutExtension
(
)
)
)
;
}
private
function
assertFilenameGenerator
(
PathnameStrategyInterface
$strategy
)
: void
{
$jpg
=
$this
->
getJpg
(
)
;
$mediaWithThumbnail
=
$this
->
getMediaWithThumbnail
(
)
;
static
::
assertSame
(
'jpgFileWithExtension.jpg',
$strategy
->
generatePhysicalFilename
(
$jpg
)
)
;
static
::
assertSame
(
'jpgFileWithExtension_200x200.jpg',
$strategy
->
generatePhysicalFilename
(
$jpg
,
$mediaWithThumbnail
->
getThumbnails
(
)
->
first
(
)
)
)
;
}
}
/** * @throws MediaException */
public
function
getRelativeMediaUrl
(
MediaEntity
$media
)
: string
{
$this
->
validateMedia
(
$media
)
;
return
$this
->
toPathString
(
[
'media',
$this
->pathnameStrategy->
generatePathHash
(
$media
)
,
$this
->pathnameStrategy->
generatePathCacheBuster
(
$media
)
,
$this
->pathnameStrategy->
generatePhysicalFilename
(
$media
)
,
]
)
;
}
/** * @throws MediaException */
public
function
getAbsoluteMediaUrl
(
MediaEntity
$media
)
: string
{
return
$this
->filesystem->
publicUrl
(
$this
->
getRelativeMediaUrl
(
$media
)
)
;
}