All Data Structures Namespaces Files Functions Variables
ARestfullController.php
Go to the documentation of this file.
<?php
namespace Tools;
abstract class RestfullController extends AController
{
private $encode_fnc;
public function __construct($context, $params, $encode_fnc = null)
{
if (!\Entity\Config::getConfig(null, "restfullEnabled", false))
throw new \Exception\Error404();
parent::__construct($context, $params);
if ($encode_fnc === null)
$encode_fnc = array("method" => json_encode, "mime" => "application/json");
$this->encode_fnc = $encode_fnc;
}
public function start()
{
//TODO call some hooks
header("Content-Type: {$this->encode_fnc["mime"]}");
echo $this->encode_fnc["method"]($this->run());
//TODO call some hooks
}
abstract public function run();
}
Tools\RestfullController\__construct
__construct($context, $params, $encode_fnc=null)
Definition: ARestfullController.php:12
Entity
Definition: Address.php:3
Tools\RestfullController\$encode_fnc
$encode_fnc
Definition: ARestfullController.php:10
Tools\RestfullController
Definition: ARestfullController.php:8
Tools
Definition: AController.php:3
Tools\AController
Definition: AController.php:8
Tools\RestfullController\start
start()
Definition: ARestfullController.php:22