Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
arrayPrototype example
public
function
testPrototypeFloat
(
)
{
$node
=
new
ArrayNodeDefinition
(
'root'
)
;
$this
->
assertEquals
(
$node
->
prototype
(
'float'
)
,
$node
->
floatPrototype
(
)
)
;
}
public
function
testPrototypeArray
(
)
{
$node
=
new
ArrayNodeDefinition
(
'root'
)
;
$this
->
assertEquals
(
$node
->
prototype
(
'array'
)
,
$node
->
arrayPrototype
(
)
)
;
}
public
function
testPrototypeEnum
(
)
{
$node
=
new
ArrayNodeDefinition
(
'root'
)
;
$this
->
assertEquals
(
$node
->
prototype
(
'enum'
)
,
$node
->
enumPrototype
(
)
)
;
}
public
static
function
getEnableableNodeFixtures
(
)
: array
{
return
[
[
[
$data
=
[
'first' =>
[
'foo' => 'bar'
]
]
;
$this
->
assertNormalized
(
$tree
,
$data
,
$data
)
;
}
public
function
testFloatLikeValueAsMapKeyAttribute
(
)
{
$tree
=
(
new
TreeBuilder
(
'root'
)
)
->
getRootNode
(
)
->
useAttributeAsKey
(
'number'
)
->
arrayPrototype
(
)
->
children
(
)
->
scalarNode
(
'foo'
)
->
end
(
)
->
end
(
)
->
end
(
)
->
end
(
)
->
buildTree
(
)
;
$this
->
assertNormalized
(
$tree
,
[
[
'number' => 3.0,
->
scalarNode
(
'first'
)
->
end
(
)
->
scalarNode
(
'second'
)
->
end
(
)
->
scalarNode
(
'third'
)
->
end
(
)
->
end
(
)
->
end
(
)
->
arrayNode
(
'messenger'
)
->
children
(
)
->
arrayNode
(
'transports'
)
->
normalizeKeys
(
false
)
->
useAttributeAsKey
(
'name'
)
->
arrayPrototype
(
)
->
fixXmlConfig
(
'option'
)
->
children
(
)
->
scalarNode
(
'dsn'
)
->
end
(
)
->
scalarNode
(
'serializer'
)
->
defaultNull
(
)
->
end
(
)
->
arrayNode
(
'options'
)
->
normalizeKeys
(
false
)
->
defaultValue
(
[
]
)
->
prototype
(
'variable'
)
->
end
(
)
->
end
(
)
->
end
(
)
return
$rootNode
;
}
private
function
createApiSection
(
)
: ArrayNodeDefinition
{
$rootNode
=
(
new
TreeBuilder
(
'api'
)
)
->
getRootNode
(
)
;
$rootNode
->
children
(
)
->
arrayNode
(
'rate_limiter'
)
->
useAttributeAsKey
(
'name'
)
->
arrayPrototype
(
)
->
children
(
)
->
booleanNode
(
'enabled'
)
->
defaultTrue
(
)
->
end
(
)
->
scalarNode
(
'lock_factory'
)
->
defaultValue
(
'lock.factory'
)
->
end
(
)
->
scalarNode
(
'policy'
)
->
end
(
)
->
scalarNode
(
'limit'
)
->
end
(
)
->
scalarNode
(
'cache_pool'
)
->
defaultValue
(
'cache.rate_limiter'
)
->
end
(
)
->
scalarNode
(
'interval'
)
->
end
(
)
->
scalarNode
(
'reset'
)
->
end
(
)
->
arrayNode
(
'rate'
)
->
children
(
)
->
scalarNode
(
'interval'
)
->
end
(
)
continue
;
}
$tmp
=
$v
;
unset
(
$values
[
$k
]
)
;
$values
[
$k
]
[
'services'
]
=
$tmp
;
}
return
$values
;
}
)
->
end
(
)
->
arrayPrototype
(
)
->
fixXmlConfig
(
'service'
)
->
children
(
)
->
arrayNode
(
'services'
)
->
prototype
(
'scalar'
)
->
end
(
)
->
end
(
)
->
end
(
)
->
end
(
)
->
end
(
)
->
end
(
)
->
end
(
)
->
end
(
)
;