Cmstop what controllers and methods are passed---instantiate the controller

Source: Internet
Author: User

Object Top class
Class object

First level abstract class controller
Abstract class Controller extends object


Second level abstract class Controller_abstract inherit controller grandfather class

Abstract class Controller_abstract extends controller

cmstop.php Main Program
Set property public $app, $controller, $action
The module, controller, and method used to receive and save the current request
Instantiate the object,
$obj = new $this->class ($this);
Instantiate the $this in cmstop.php.
The $this->controller= content that was received this time
So. Instantiate the content class, calling the method execute () when it is not. Just look in the parent class.
$response = $obj->execute ();
The Execute method is in the parent class Controller_abstract
All current controllers. are inherited from this parent class abstract class Controller_abstract

The $this in the parent class is the class name Controller_admin_content
(attribute $this->controller= content when instantiated)
The $this->app of the parent class is when it is instantiated. All properties that contain values
The $this->app->action of the parent class is the Action property in all properties

Abstract the role of the parent class:

if ($this->action_exists ($this->app->action))//Determine if the current class exists a method exists let him run: Call him.
User--The method--array
{
$response = Call_user_func_array (Array ($this, $this->app->action), $this->app->args);
}

This ensures that the. $_get passes over what controller. Cmstop is the controller to instantiate.
And call the object's parent class in the abstract class method, $response = $obj->execute ();
At the time of instantiation. What is the controller. What method. Call the Controller and method
Call_user_func_array (Array ($this, $this->app->action)

Defining common properties in the main program
Class Cmstop extends Object
Public $app, $controller, $action
Receive parameters for user requests
$this->app = ' system ';
$this->controller = ' content ';
$this->action = ' index ';

Instantiate $this. is to pass these attributes as parameters to the Controller_admin_content class. and trigger the constructor method.
$obj = new $this->class ($this);
Passed to the parent class's constructor,
Parent class checks for the presence of a requested method
if ($this->action_exists ($this->app->action))
There, call him.
$response = Call_user_func_array (Array ($this, $this->app->action), $this->app->args);

$obj = new $this->class ($this);
When instantiated. 2 things have been done.
1 instantiate the Controller class in this attribute.
2 The property value as an argument, passed to the constructor of the class, and then passed to the constructor of the parent class


Class Controller_admin_content extends Controller_abstract
function __construct (& $app)
{
Parent::__construct ($app);
}

Cmstop what controllers and methods are passed---instantiate the controller

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.