Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getTaggedIteratorArgument example
$this
->
assertSame
(
'cache.app',
$def
->
getTag
(
'cache.taggable'
)
[
0
]
[
'pool'
]
?? null
)
;
}
public
function
testCachePoolInvalidateTagsCommandRegistered
(
)
{
$container
=
$this
->
createContainerFromFile
(
'cache'
)
;
$this
->
assertTrue
(
$container
->
hasDefinition
(
'console.command.cache_pool_invalidate_tags'
)
)
;
$locator
=
$container
->
getDefinition
(
'console.command.cache_pool_invalidate_tags'
)
->
getArgument
(
0
)
;
$this
->
assertInstanceOf
(
ServiceLocatorArgument::
class
,
$locator
)
;
$iterator
=
$locator
->
getTaggedIteratorArgument
(
)
;
$this
->
assertInstanceOf
(
TaggedIteratorArgument::
class
,
$iterator
)
;
$this
->
assertSame
(
'cache.taggable',
$iterator
->
getTag
(
)
)
;
$this
->
assertSame
(
'pool',
$iterator
->
getIndexAttribute
(
)
)
;
$this
->
assertTrue
(
$iterator
->
needsIndexes
(
)
)
;
}
public
function
testRemovesResourceCheckerConfigCacheFactoryArgumentOnlyIfNoDebug
(
)
{
$container
=
$this
->
createContainer
(
[
'kernel.debug' => true
]
)
;
(
new
FrameworkExtension
(
)
)
->
load
(
[
[
'annotations' => false, 'http_method_override' => false, 'handle_all_throwables' => true, 'php_errors' =>
[
'log' => true
]
]
]
,
$container
)
;
private
function
dumpValue
(
mixed
$value
)
: mixed
{
if
(
$value
instanceof ServiceClosureArgument
)
{
$value
=
$value
->
getValues
(
)
[
0
]
;
return
new
TaggedValue
(
'service_closure',
$this
->
dumpValue
(
$value
)
)
;
}
if
(
$value
instanceof ArgumentInterface
)
{
$tag
=
$value
;
if
(
$value
instanceof TaggedIteratorArgument
||
(
$value
instanceof ServiceLocatorArgument &&
$tag
=
$value
->
getTaggedIteratorArgument
(
)
)
)
{
if
(
null ===
$tag
->
getIndexAttribute
(
)
)
{
$content
=
$tag
->
getTag
(
)
;
}
else
{
$content
=
[
'tag' =>
$tag
->
getTag
(
)
,
'index_by' =>
$tag
->
getIndexAttribute
(
)
,
]
;
if
(
null !==
$tag
->
getDefaultIndexMethod
(
)
)
{
$content
[
'default_index_method'
]
=
$tag
->
getDefaultIndexMethod
(
)
;
}
private
function
dumpValue
(
mixed
$value
)
: mixed
{
if
(
$value
instanceof ServiceClosureArgument
)
{
$value
=
$value
->
getValues
(
)
[
0
]
;
return
new
TaggedValue
(
'service_closure',
$this
->
dumpValue
(
$value
)
)
;
}
if
(
$value
instanceof ArgumentInterface
)
{
$tag
=
$value
;
if
(
$value
instanceof TaggedIteratorArgument
||
(
$value
instanceof ServiceLocatorArgument &&
$tag
=
$value
->
getTaggedIteratorArgument
(
)
)
)
{
if
(
null ===
$tag
->
getIndexAttribute
(
)
)
{
$content
=
$tag
->
getTag
(
)
;
}
else
{
$content
=
[
'tag' =>
$tag
->
getTag
(
)
,
'index_by' =>
$tag
->
getIndexAttribute
(
)
,
]
;
if
(
null !==
$tag
->
getDefaultIndexMethod
(
)
)
{
$content
[
'default_index_method'
]
=
$tag
->
getDefaultIndexMethod
(
)
;
}
final
class
ServiceLocatorTagPass
extends
AbstractRecursivePass
{
use
PriorityTaggedServiceTrait;
protected
bool
$skipScalars
= true;
protected
function
processValue
(
mixed
$value
, bool
$isRoot
= false
)
: mixed
{
if
(
$value
instanceof ServiceLocatorArgument
)
{
if
(
$value
->
getTaggedIteratorArgument
(
)
)
{
$value
->
setValues
(
$this
->
findAndSortTaggedServices
(
$value
->
getTaggedIteratorArgument
(
)
,
$this
->container
)
)
;
}
return
self::
register
(
$this
->container,
$value
->
getValues
(
)
)
;
}
if
(
$value
instanceof Definition
)
{
$value
->
setBindings
(
parent::
processValue
(
$value
->
getBindings
(
)
)
)
;
}
if
(
!
$value
instanceof Definition || !
$value
->
hasTag
(
'container.service_locator'
)
)
{
$withKeys
= !
array_is_list
(
$parameters
)
;
foreach
(
$parameters
as
$key
=>
$value
)
{
$element
=
$this
->document->
createElement
(
$type
)
;
if
(
$withKeys
)
{
$element
->
setAttribute
(
$keyAttribute
,
$key
)
;
}
if
(
\
is_array
(
$tag
=
$value
)
)
{
$element
->
setAttribute
(
'type', 'collection'
)
;
$this
->
convertParameters
(
$value
,
$type
,
$element
, 'key'
)
;
}
elseif
(
$value
instanceof TaggedIteratorArgument
||
(
$value
instanceof ServiceLocatorArgument &&
$tag
=
$value
->
getTaggedIteratorArgument
(
)
)
)
{
$element
->
setAttribute
(
'type',
$value
instanceof TaggedIteratorArgument ? 'tagged_iterator' : 'tagged_locator'
)
;
$element
->
setAttribute
(
'tag',
$tag
->
getTag
(
)
)
;
if
(
null !==
$tag
->
getIndexAttribute
(
)
)
{
$element
->
setAttribute
(
'index-by',
$tag
->
getIndexAttribute
(
)
)
;
if
(
null !==
$tag
->
getDefaultIndexMethod
(
)
)
{
$element
->
setAttribute
(
'default-index-method',
$tag
->
getDefaultIndexMethod
(
)
)
;
}
if
(
null !==
$tag
->
getDefaultPriorityMethod
(
)
)
{
$element
->
setAttribute
(
'default-priority-method',
$tag
->
getDefaultPriorityMethod
(
)
)
;
}
$withKeys
= !
array_is_list
(
$parameters
)
;
foreach
(
$parameters
as
$key
=>
$value
)
{
$element
=
$this
->document->
createElement
(
$type
)
;
if
(
$withKeys
)
{
$element
->
setAttribute
(
$keyAttribute
,
$key
)
;
}
if
(
\
is_array
(
$tag
=
$value
)
)
{
$element
->
setAttribute
(
'type', 'collection'
)
;
$this
->
convertParameters
(
$value
,
$type
,
$element
, 'key'
)
;
}
elseif
(
$value
instanceof TaggedIteratorArgument
||
(
$value
instanceof ServiceLocatorArgument &&
$tag
=
$value
->
getTaggedIteratorArgument
(
)
)
)
{
$element
->
setAttribute
(
'type',
$value
instanceof TaggedIteratorArgument ? 'tagged_iterator' : 'tagged_locator'
)
;
$element
->
setAttribute
(
'tag',
$tag
->
getTag
(
)
)
;
if
(
null !==
$tag
->
getIndexAttribute
(
)
)
{
$element
->
setAttribute
(
'index-by',
$tag
->
getIndexAttribute
(
)
)
;
if
(
null !==
$tag
->
getDefaultIndexMethod
(
)
)
{
$element
->
setAttribute
(
'default-index-method',
$tag
->
getDefaultIndexMethod
(
)
)
;
}
if
(
null !==
$tag
->
getDefaultPriorityMethod
(
)
)
{
$element
->
setAttribute
(
'default-priority-method',
$tag
->
getDefaultPriorityMethod
(
)
)
;
}
final
class
ServiceLocatorTagPass
extends
AbstractRecursivePass
{
use
PriorityTaggedServiceTrait;
protected
function
processValue
(
mixed
$value
, bool
$isRoot
= false
)
: mixed
{
if
(
$value
instanceof ServiceLocatorArgument
)
{
if
(
$value
->
getTaggedIteratorArgument
(
)
)
{
$value
->
setValues
(
$this
->
findAndSortTaggedServices
(
$value
->
getTaggedIteratorArgument
(
)
,
$this
->container
)
)
;
}
return
self::
register
(
$this
->container,
$value
->
getValues
(
)
)
;
}
if
(
$value
instanceof Definition
)
{
$value
->
setBindings
(
parent::
processValue
(
$value
->
getBindings
(
)
)
)
;
}
if
(
!
$value
instanceof Definition || !
$value
->
hasTag
(
'container.service_locator'
)
)
{