PHP Class Pop\Mvc\Controller

Author: Nick Sagona, III ([email protected])
Show file Open project: nicksagona/PopPHP Class Usage Examples

Protected Properties

Property Type Description
$errorAction string Error action
$project Pop\Project\Project Project config object
$request Pop\Http\Request Request
$response Pop\Http\Response Response
$view View View object
$viewPath string View path

Public Methods

Method Description
__construct ( Pop\Http\Request $request = null, Pop\Http\Response $response = null, Project $project = null, string $viewPath = null ) : Controller Constructor
dispatch ( string $action = 'index' ) : Controller Dispatch the controller based on the action
getErrorAction ( ) : string Get the error action
getProject ( ) : Project Get the project object
getRequest ( ) : Pop\Http\Request Get the request object
getResponse ( ) : Pop\Http\Response Get the response object
getView ( ) : View Get the view object
getViewPath ( ) : string Get the view path
send ( integer $code = 200, array $headers = null ) : void Finalize the request and send the response.
sendJson ( mixed $values, integer $code = 200, array $headers = null ) : void Method to send a JSON response
setErrorAction ( string $error ) : Controller Set the error action
setProject ( Project $project ) : Controller Set the response object
setRequest ( Pop\Http\Request $request ) : Controller Set the request object
setResponse ( Pop\Http\Response $response ) : Controller Set the response object
setViewPath ( string $viewPath ) : Controller Set the response object

Method Details

__construct() public method

Instantiate the controller object
public __construct ( Pop\Http\Request $request = null, Pop\Http\Response $response = null, Project $project = null, string $viewPath = null ) : Controller
$request Pop\Http\Request
$response Pop\Http\Response
$project Pop\Project\Project
$viewPath string
return Controller

dispatch() public method

Dispatch the controller based on the action
public dispatch ( string $action = 'index' ) : Controller
$action string
return Controller

getErrorAction() public method

Get the error action
public getErrorAction ( ) : string
return string

getProject() public method

Get the project object
public getProject ( ) : Project
return Pop\Project\Project

getRequest() public method

Get the request object
public getRequest ( ) : Pop\Http\Request
return Pop\Http\Request

getResponse() public method

Get the response object
public getResponse ( ) : Pop\Http\Response
return Pop\Http\Response

getView() public method

Get the view object
public getView ( ) : View
return View

getViewPath() public method

Get the view path
public getViewPath ( ) : string
return string

send() public method

Finalize the request and send the response.
public send ( integer $code = 200, array $headers = null ) : void
$code integer
$headers array
return void

sendJson() public method

Method to send a JSON response
public sendJson ( mixed $values, integer $code = 200, array $headers = null ) : void
$values mixed
$code integer
$headers array
return void

setErrorAction() public method

Set the error action
public setErrorAction ( string $error ) : Controller
$error string
return Controller

setProject() public method

Set the response object
public setProject ( Project $project ) : Controller
$project Pop\Project\Project
return Controller

setRequest() public method

Set the request object
public setRequest ( Pop\Http\Request $request ) : Controller
$request Pop\Http\Request
return Controller

setResponse() public method

Set the response object
public setResponse ( Pop\Http\Response $response ) : Controller
$response Pop\Http\Response
return Controller

setViewPath() public method

Set the response object
public setViewPath ( string $viewPath ) : Controller
$viewPath string
return Controller

Property Details

$errorAction protected property

Error action
protected string $errorAction
return string

$project protected property

Project config object
protected Project,Pop\Project $project
return Pop\Project\Project

$request protected property

Request
protected Request,Pop\Http $request
return Pop\Http\Request

$response protected property

Response
protected Response,Pop\Http $response
return Pop\Http\Response

$view protected property

View object
protected View,Pop\Mvc $view
return View

$viewPath protected property

View path
protected string $viewPath
return string