AD0-E716 · Question #21
An Adobe Commerce Developer wishes to add an action to a pre-existing route, but does not wish to interfere with the functionality of the actions from the original route. What must the developer do…
The correct answer is A. In the route declaration, use the before or after parameters to load their module in before or after. To add an action to a pre-existing route without interfering with the functionality of the original route, the developer must use the before or after parameters in the route declaration. This will load the developer's module in before or after the original module, respectively…
Question
An Adobe Commerce Developer wishes to add an action to a pre-existing route, but does not wish to interfere with the functionality of the actions from the original route. What must the developer do to ensure that their action works without any side effects in the original module?
Options
- AIn the route declaration, use the before or after parameters to load their module in before or after
- BInject the new action into the standard router constructor's $actiomist parameter.
- CAdd the action into to the controllers/front_name/ in My.Module, Magento will automatically
How the community answered
(27 responses)- A81% (22)
- B7% (2)
- C11% (3)
Explanation
To add an action to a pre-existing route without interfering with the functionality of the original route, the developer must use the before or after parameters in the route declaration. This will load the developer's module in before or after the original module, respectively. For example, the following code would add an action to the my_module/index route before the action from the original module: <route id="my_module/index"> <before>my_module_before</before> <action class="MyModule\Controller\Index"> <argument name="context" type="Magento\Framework\App\Action\Context"/> The my_module_before action would be executed before the MyModule\Controller\Index action, which would allow the developer to perform any necessary setup before the original action is
Topics
Community Discussion
No community discussion yet for this question.