Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setConfigCacheFactory example
$container
->
setParameter
(
'parameter.condition',
$parameter
)
;
$router
=
new
Router
(
$container
, 'with_condition.yaml',
[
'debug' => true,
'cache_dir' =>
$cacheDir
,
]
)
;
$resourceCheckers
=
[
new
ContainerParametersResourceChecker
(
$container
)
,
]
;
$router
->
setConfigCacheFactory
(
new
ResourceCheckerConfigCacheFactory
(
$resourceCheckers
)
)
;
$router
->
getMatcher
(
)
; // trigger cache build
$cache
=
new
ResourceCheckerConfigCache
(
$cacheDir
.\DIRECTORY_SEPARATOR.'url_matching_routes.php',
$resourceCheckers
)
;
$this
->
assertTrue
(
$cache
->
isFresh
(
)
)
;
}
finally
{
if
(
is_dir
(
$cacheDir
)
)
{
array_map
(
'unlink',
glob
(
$cacheDir
.\DIRECTORY_SEPARATOR.'*'
)
)
;
rmdir
(
$cacheDir
)
;
}
}