Posts tagged ‘Controllers’

Controllers

Controllers
Controllers are the starting point for all business logic inMagento. The line between what is considered business logic (rules that define a business’s methodology) and what is domain logic (instructions about a set of data) is blurry in Magento. Some people would consider checking for required and optional form fields as “business logic”, other peoplewould consider that “domain logic”. Most of the logic inMagento is done in the models.

Controllers extend a base class of Mage_Core_Controller_Varien_Action, which is a close copy of the Zend Framework class Zend_Controller_Action. The important methods of this class are:

• dispatch($action)
• preDispatch()
• postDispatch()

The rest of the methods are simply utility URLs to pass commands to other key parts of the system. The dispatch method starts all the business logic of the current request. The value of $action is determined from the URL and is generally “index” as a default. The dispatch method first calls preDispatch which triggers some events which you can listen for:
• controller_action_predispatch
• controller_action_predispatch_ModuleName
•controller_action_predispatch_ModuleName_ControllerName_ActionName

The dispatch method is called only if the preDispatch method does not mark the request as being dispatched already. The dispatch method calls the

particular action method in the desired cocontrollerntroller instance

September 10, 2009 at 3:18 am Leave a comment


Recent Posts

Categories

Archives

Top Posts

    Top Rated

    Blog Stats

    • 6,373 hits

     

    June 2012
    M T W T F S S
    « Sep    
     123
    45678910
    11121314151617
    18192021222324
    252627282930  

    Follow

    Get every new post delivered to your Inbox.