What would be the plugin execution order?

The di. xml file of a module attaches two plugins for the class Action.

The PluginA has the methods: beforeDispatch, aroundDispatch, afterDispatch.

The PluginB has the methods: beforeDispatch, afterDispatch.

The around plugin code is:

What would be the plugin execution order?

A)

B)

C)

A . Option A
B. Option B
C. Option C

Answer: C

Explanation:

The plugin execution order is as follows:

PluginA::beforeDispatch()

PluginB::beforeDispatch()

PluginA::aroundDispatch()

The code in the around plugin

PluginB::afterDispatch()

PluginA::afterDispatch()

The aroundDispatch() method is executed in a separate scope, so the code in the around plugin will be executed after the beforeDispatch() methods of both plugins, but before the afterDispatch() methods of both plugins.

Here is a diagram that shows the plugin execution order:

PluginA

beforeDispatch()

aroundDispatch()

afterDispatch()

PluginB

beforeDispatch()

afterDispatch()

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments