Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
SerializerExtension example
$runtime
=
new
SerializerRuntime
(
new
Serializer
(
[
new
ObjectNormalizer
(
$meta
)
]
,
[
new
JsonEncoder
(
)
,
new
YamlEncoder
(
)
]
)
)
;
$mockRuntimeLoader
=
$this
->
createMock
(
RuntimeLoaderInterface::
class
)
;
$mockRuntimeLoader
->
method
(
'load'
)
->
willReturnMap
(
[
[
'Symfony\Bridge\Twig\Extension\SerializerRuntime',
$runtime
]
,
]
)
;
$twig
=
new
Environment
(
new
ArrayLoader
(
[
'template' =>
$template
]
)
)
;
$twig
->
addExtension
(
new
SerializerExtension
(
)
)
;
$twig
->
addRuntimeLoader
(
$mockRuntimeLoader
)
;
return
$twig
;
}
}