You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PlexShare/fuel/core/classes/controller.php

81 lines
1.6 KiB

<?php
/**
* Part of the Fuel framework.
*
* @package Fuel
* @version 1.8
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @link http://fuelphp.com
*/
namespace Fuel\Core;
abstract class Controller
{
/**
* @var Request The current Request object
*/
public $request;
/**
* @var Integer The default response status
*/
public $response_status = 200;
/**
* Sets the controller request object.
*
* @param \Request $request The current request object
*/
public function __construct(\Request $request)
{
$this->request = $request;
}
/**
* This method gets called before the action is called
*/
public function before() {}
/**
* This method gets called after the action is called
* @param \Response|string $response
* @return \Response
*/
public function after($response)
{
// Make sure the $response is a Response object
if ( ! $response instanceof Response)
{
$response = \Response::forge($response, $this->response_status);
}
return $response;
}
/**
* This method returns the named parameter requested, or all of them
* if no parameter is given.
*
* @param string $param The name of the parameter
* @param mixed $default Default value
* @return mixed
*/
public function param($param, $default = null)
{
return $this->request->param($param, $default);
}
/**
* This method returns all of the named parameters.
*
* @return array
*/
public function params()
{
return $this->request->params();
}
}