Class MVCnPHP_Controller

Description

The controller part of the MVC

This class controls processing for the program indiscriminately. The focus is always on the underlying views or commands. This class allows you to store application messages such as status messages (e.g. something was saved successfully) or error messages from failed validation or security reasons. By default these are stored in the $_SESSION superglobal in $_SESSION['MVC_MESSAGE'] and $_SESSION['MVC_ERRORS'] respectively (note: the later is an array). If your application is not using PHP4 sessions you will want to follow the directions given in the documentation for Controller::_clearMessages

Located in /Controller.php (line 50)


	
			
Variable Summary
string $baseURL
string $commandDir
array $configData
object $mapLoader
object $mapping
string $mvcBase
string $object
array $request
string $viewDir
Method Summary
MVCnPHP_Controller __construct (variant $configData, [string $configType = MVC_XML], [string $allowedFormMethod = MVC_BOTH])
void checkMethod ()
void clearMessages ()
void forwardControl (string $name)
boolean isForward (string $name)
void loadMapping (string $configType, variant $configData)
string processRequest ()
void setBaseURL (string $url)
boolean setCommandDir (string $path)
boolean setMVCBase (string $path)
boolean setViewDir (string $path)
Variables
int $allowedFormMethod = null (line 56)
  • access: private
string $baseURL = null (line 104)
  • access: private
string $commandDir = null (line 98)
  • access: private
array $configData = null (line 116)
  • access: private
int $configType = null (line 110)
  • access: private
object $mapLoader = null (line 74)
  • access: private
object $mapping = null (line 80)
  • access: private
string $mvcBase = null (line 86)
  • access: private
string $object = null (line 68)
  • access: private
array $request = null (line 62)
  • access: private
string $viewDir = null (line 92)
  • access: private
Methods
Constructor __construct (line 131)

Constructor

Loads MVC configuration data and sets up data needed for further processing

MVCnPHP_Controller __construct (variant $configData, [string $configType = MVC_XML], [string $allowedFormMethod = MVC_BOTH])
  • variant $configData: Configuration data
  • string $configType: Denotes type of config data structure, MVC_ARRAY or MVC_XML
  • string $allowedFormMethod: Controller can accept MVC_GET, MVC_POST or MVC_BOTH
checkMethod (line 363)

Ensures only supported methods are used

void checkMethod ()
clearMessages (line 350)

Clears any existing errors or messages

This method assumes the application is using PHP4 sessions to store MVC errors and messages. If that is not the case, the application should create a new class that extends this controller and override this function to clear the messages in the way desired.

void clearMessages ()
forwardControl (line 446)

Forwards control onto another command or view

A model will typically try to forward control to a view (less likely, but possible, another command) after processing. This object handles that forwarding and can even handle forwarding to a different URL if configured to do so.

void forwardControl (string $name)
  • string $name: Name of next model or view to go to
isForward (line 424)

Determines if string is a name of an existing forward.

Because views can return the HTML string it won't be obvious if the call to the view's getView() is a forward or actually HTML. This function makes that determintation.

  • return: True if forward is found, otherwise false
  • access: public
  • author: Tony Bibbs <tony@geeklog.net>
boolean isForward (string $name)
  • string $name: Name of forward to look for
loadMapping (line 389)

Loads the mapping data for a model or view

This will load only the mapping data needed by the current object.

void loadMapping (string $configType, variant $configData)
  • string $configType: Dontes the type of config data structure
  • variant $configData: this is the data or file pointer for config data
processRequest (line 240)

Process a request (or forward)

NOTE this now supports the concept of a global forward for descendants of the validator class. A global forward is a slick way for validators to return control to the calling command or view without having define a bunch of them in the configuration file.

  • return: Optional, may return HTML string of view
  • access: public
  • author: Tony Bibbs <tony@geeklog.net>
string processRequest ()
setBaseURL (line 221)

Sets base URL for this controller

The base url allows all subsequent references to URL's to be relative to the URL specified here

  • access: public
  • author: Tony Bibbs
void setBaseURL (string $url)
  • string $url: Base URL
setCommandDir (line 201)

Sets location of commands for this controller

  • return: True if view path is set, otherwise false
  • access: public
  • author: Tony Bibbs
boolean setCommandDir (string $path)
  • string $path: Path to command dir, must end with trailing slash
setMVCBase (line 165)

Sets location of the base MVC package so other MVC classes can be loaded at a later time.

  • return: True if view path is set, otherwise false
  • access: public
  • author: Tony Bibbs
boolean setMVCBase (string $path)
  • string $path: Path to MVC base dir, must end with trailing slash
setViewDir (line 183)

Sets location of views for this controller

  • return: True if view path is set, otherwise false
  • access: public
  • author: Tony Bibbs
boolean setViewDir (string $path)
  • string $path: Path to view dir, must end with trailing slash

Documentation generated on Mon, 7 Mar 2005 22:36:21 -0600 by phpDocumentor 1.3.0RC3