Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setHotPathEvents example
}
/** * @return void */
public
function
build
(
ContainerBuilder
$container
)
{
parent::
build
(
$container
)
;
$registerListenersPass
=
new
RegisterListenersPass
(
)
;
$registerListenersPass
->
setHotPathEvents
(
[
KernelEvents::REQUEST,
KernelEvents::CONTROLLER,
KernelEvents::CONTROLLER_ARGUMENTS,
KernelEvents::RESPONSE,
KernelEvents::FINISH_REQUEST,
]
)
;
if
(
class_exists
(
ConsoleEvents::
class
)
)
{
$registerListenersPass
->
setNoPreloadEvents
(
[
ConsoleEvents::COMMAND,
ConsoleEvents::TERMINATE,
ConsoleEvents::ERROR,
]
)
;
$this
->
assertEquals
(
$expectedCalls
,
$definition
->
getMethodCalls
(
)
)
;
}
public
function
testHotPathEvents
(
)
{
$container
=
new
ContainerBuilder
(
)
;
$container
->
register
(
'foo', SubscriberService::
class
)
->
addTag
(
'kernel.event_subscriber',
[
]
)
;
$container
->
register
(
'event_dispatcher', 'stdClass'
)
;
(
new
RegisterListenersPass
(
)
)
->
setHotPathEvents
(
[
'event'
]
)
->
process
(
$container
)
;
$this
->
assertTrue
(
$container
->
getDefinition
(
'foo'
)
->
hasTag
(
'container.hot_path'
)
)
;
}
public
function
testNoPreloadEvents
(
)
{
$container
=
new
ContainerBuilder
(
)
;
$container
->
register
(
'foo', SubscriberService::
class
)
->
addTag
(
'kernel.event_subscriber',
[
]
)
;
$container
->
register
(
'bar'
)
->
addTag
(
'kernel.event_listener',
[
'event' => 'cold_event'
]
)
;
$container
->
register
(
'baz'
)