Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
treatTrueLike example
public
function
canBeEnabled
(
)
:
static
{
$this
->
addDefaultsIfNotSet
(
)
->
treatFalseLike
(
[
'enabled' => false
]
)
->
treatTrueLike
(
[
'enabled' => true
]
)
->
treatNullLike
(
[
'enabled' => true
]
)
->
beforeNormalization
(
)
->
ifArray
(
)
->
then
(
function
Darray
$v
)
{
$v
[
'enabled'
]
??= true;
return
$v
;
}
)
->
end
(
)
->
children
(
)
->
booleanNode
(
'enabled'
)
->
end
(
)
->
end
(
)
;
}
private
function
addCsrfSection
(
ArrayNodeDefinition
$rootNode
)
: void
{
$rootNode
->
children
(
)
->
arrayNode
(
'csrf_protection'
)
->
treatFalseLike
(
[
'enabled' => false
]
)
->
treatTrueLike
(
[
'enabled' => true
]
)
->
treatNullLike
(
[
'enabled' => true
]
)
->
addDefaultsIfNotSet
(
)
->
children
(
)
// defaults to framework.session.enabled && !class_exists(FullStack::class) && interface_exists(CsrfTokenManagerInterface::class) ->
booleanNode
(
'enabled'
)
->
defaultNull
(
)
->
end
(
)
->
end
(
)
->
end
(
)
->
end
(
)
;
}
->
scalarNode
(
'request_matcher'
)
->
end
(
)
->
scalarNode
(
'access_denied_url'
)
->
end
(
)
->
scalarNode
(
'access_denied_handler'
)
->
end
(
)
->
scalarNode
(
'entry_point'
)
->
info
(
sprintf
(
'An enabled authenticator name or a service id that implements "%s"', AuthenticationEntryPointInterface::
class
)
)
->
end
(
)
->
scalarNode
(
'provider'
)
->
end
(
)
->
booleanNode
(
'stateless'
)
->
defaultFalse
(
)
->
end
(
)
->
booleanNode
(
'lazy'
)
->
defaultFalse
(
)
->
end
(
)
->
scalarNode
(
'context'
)
->
cannotBeEmpty
(
)
->
end
(
)
->
arrayNode
(
'logout'
)
->
treatTrueLike
(
[
]
)
->
canBeUnset
(
)
->
beforeNormalization
(
)
->
ifTrue
(
fn
(
$v
)
: bool =>
isset
(
$v
[
'csrf_token_generator'
]
)
&& !
isset
(
$v
[
'csrf_token_manager'
]
)
)
->
then
(
function
Darray
$v
)
: array
{
$v
[
'csrf_token_manager'
]
=
$v
[
'csrf_token_generator'
]
;
return
$v
;
}
)
->
end
(
)
->
beforeNormalization
(
)
->
ifTrue
(
fn
(
$v
)
: bool => \
is_array
(
$v
)
&&
(
isset
(
$v
[
'csrf_token_manager'
]
)
xor
isset
(
$v
[
'enable_csrf'
]
)
)
)