Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
RequestAttributeValueResolver example
if
(
null !==
$namedResolvers
)
{
$namedResolvers
=
new
ServiceLocator
(
array_map
(
fn
(
$resolver
)
=>
fn
(
)
=>
$resolver
,
$namedResolvers
)
)
;
}
return
new
ArgumentResolver
(
new
ArgumentMetadataFactory
(
)
,
$chainableResolvers
,
$namedResolvers
)
;
}
public
function
testDefaultState
(
)
{
$this
->
assertEquals
(
self::
getResolver
(
)
,
new
ArgumentResolver
(
)
)
;
$this
->
assertNotEquals
(
self::
getResolver
(
)
,
new
ArgumentResolver
(
null,
[
new
RequestAttributeValueResolver
(
)
]
)
)
;
}
public
function
testGetArguments
(
)
{
$request
= Request::
create
(
'/'
)
;
$request
->attributes->
set
(
'foo', 'foo'
)
;
$controller
=
[
new
self
(
)
, 'controllerWithFoo'
]
;
$this
->
assertEquals
(
[
'foo'
]
, self::
getResolver
(
)
->
getArguments
(
$request
,
$controller
)
, '->getArguments() returns an array of arguments for the controller method'
)
;
}
return
$arguments
;
}
/** * @return iterable<int, ArgumentValueResolverInterface> */
public
static
function
getDefaultArgumentValueResolvers
(
)
: iterable
{
return
[
new
RequestAttributeValueResolver
(
)
,
new
RequestValueResolver
(
)
,
new
SessionValueResolver
(
)
,
new
DefaultValueResolver
(
)
,
new
VariadicValueResolver
(
)
,
]
;
}
private
function
getPrettyName
(
$controller
)
: string
{
if
(
\
is_array
(
$controller
)
)
{
if
(
\
is_object
(
$controller
[
0
]
)
)
{
return
$arguments
;
}
/** * @return iterable<int, ArgumentValueResolverInterface> */
public
static
function
getDefaultArgumentValueResolvers
(
)
: iterable
{
return
[
new
RequestAttributeValueResolver
(
)
,
new
RequestValueResolver
(
)
,
new
SessionValueResolver
(
)
,
new
DefaultValueResolver
(
)
,
new
VariadicValueResolver
(
)
,
]
;
}
private
function
getPrettyName
(
$controller
)
: string
{
if
(
\
is_array
(
$controller
)
)
{
if
(
\
is_object
(
$controller
[
0
]
)
)
{