I am able to understand how routers are collected using collectRoutes() function. Then how magento tries to match router for the requested URL using match() function in dispatch() method.
But how magneto router initialize the specific Action Controller and Action method ?
What is the utility of controller_front_send_response_before and controller_front_send_response_after events?
I am able to understand how routers are collected using collectRoutes() function. Then how
Share
Oh, this is very easy (if I understand your question correctly).
URL always has a
route/controller/actionstructure.So once Magento resolved the
route(you said that you got how it works) it just usescontrollertoken as the first part of a classname of your controller. So for instance if your controller token ismymoduleand your extension prefix isMygroup_Myextensionit will try to instantiateMygroup_Myextension_MymoduleController. That means your file have to be located inapp/code/[community-or-local]/Mygroup/Myextension/controllers/MymoduleController.php.Then Magento will use an
actiontoken to call a method inside of your class. So in case ofactiontoken set asmyactionMagento will try to callmyactionAction()method.In fact both
controllerandactiontokens can be omitted. In this case Magento will try to instantiateMygroup_Myextension_IndexControllerand callindexAction()method of your extension.