Magento Expert Forum - Improve your Magento experience

Results 1 to 6 of 6

Front Controller

  1. #1
    Junior Member rocker's Avatar
    Join Date
    Mar 2013
    Posts
    105
    Thanks
    3
    Thanked 11 Times in 9 Posts

    Cool Front Controller

    The Front Controller has an array of “routers” that it uses to decide which module the URL should trigger so Front Controller plays a very crucial role in Magento. And do you know how to locate Front Controller class, or events that Front Controller fires and Front Controller’s responsibilities? If you are interested in these issues, please follow my article.
    I. Locate Front Controller class

    - The position of the directory: app/code/core/Mage/Core/Controller/Varien/Front.php
    - Receive all requests from browser and return HTML code.
    - Front controller uses routes of the system to define the controller and the action that are called.
    - Example: routers in the file config.xml of the Customer module.
    - Routers can receive 3 values for the bar including:

    • Standard (class Mage_Core_Controller_Varien_Router_Standard)
    • Admin (class Mage_Core_Controller_Varien_Router_Admin)
    • Default (class Mage_Core_Controller_Varien_Router_Default

    II -List all events that Front Controller fires
    – controller_front_init_before (app/code/core/Mage/Core/Controller/Varien/Front.php)

    • ‘front’ => Mage_Core_Controller_Varien_Front

    - controller_front_init_routers (app/code/core/Mage/Core/Controller/Varien/Front.php)

    • ‘front’ => Mage_Core_Controller_Varien_Front

    - controller_front_send_response_before (app/code/core/Mage/Core/Controller/Varien/Front.php)

    • ‘front’ => Mage_Core_Controller_Varien_Front

    - controller_front_send_response_after (app/code/core/Mage/Core/Controller/Varien/Front.php)

    • ‘front’ => Mage_Core_Controller_Varien_Front

    III. Explain Front Controller’s responsibilities
    – Directly receive the request from browser.

    • All requests call the function Mage_Core_Controller_Varien_Front::dispatch()

    - URL rewriting process.
    – Load the module and action controller corresponding with the requests through routers to process the requirements which are sent from clients.

    • Collect routers: admin, standard, default.
    • Use the function match() of routers to define the module and controller that are requested.
    • Call the function dispatch() of the controller requested.
    • Call the action requested.

    - Return HTML for browser

    • Call the function sendResponse() of Mage_Core_Model_Response_Http (extend from Zend_Controller_Response_Abstract).
    • Call the function sendHeaders() – use the header() function of PHP.
    • Call the function outputBody() to show the whole content of the body part:


    echo implode('', $this->_body);


    Question: Where is the value of $this > _body receive from?
    Answer: The variable $_body is an array() and Action controller added value to this variable.
    For example: When you call $this > renderLayout() in Action controller:

    $output = $this->getLayout()->getOutput();
    Mage::getSingleton('core/translate_inline')
    ->processResponseBody($output);
    $this->getResponse()->appendBody($output);

    View more threads in the same category:


  2. #2
    Junior Member
    Join Date
    Sep 2018
    Location
    Canada
    Posts
    873
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    The front controller software design pattern is listed in several pattern catalogs and related to the design of web applications. It is "a controller that handles all requests for a website", which is a useful structure for web application developers to achieve the flexibility and reuse without code redundancy.

  3. #3
    Junior Member
    Join Date
    Sep 2019
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Front Controller. A controller that handles all requests for a Web site. For a full description see P of EAA page 344. In a complex Web site there are many similar things you need to do when handling a request. These things include security, internationalization, and providing particular views for certain users.

  4. #4
    Junior Member
    Join Date
    Sep 2018
    Location
    Canada
    Posts
    873
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    The Front Controller combines all solicitation taking care of by directing solicitations through a solitary handler object. This article can complete regular conduct, which can be altered at runtime with decorators. The handler at that point dispatches to order protests for conduct specific to a solicitation.

  5. #5
    Junior Member
    Join Date
    Sep 2018
    Location
    Oman, Muscat
    Posts
    2,084
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default

    Front Controller is characterized as "a regulator that handles all solicitations for a Web webpage". It remains before a web-application and representatives solicitations to ensuing assets. It additionally gives an interface to normal conduct like security, internationalization and introducing specific perspectives to specific clients.

  6. #6
    Junior Member
    Join Date
    Sep 2018
    Location
    Oman, Muscat
    Posts
    2,084
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default

    The front regulator programming configuration design is recorded in a few example lists and identified with the plan of web applications.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •