Files
FHC-Core/application/core/APIv1_Controller.php
T
paolo 0c2c0468af - Added helper message with the functions success and error
- Added methods _success and _error to classes FHC_model and APIv1_Controller
2016-06-16 12:15:52 +02:00

64 lines
1.2 KiB
PHP

<?php
require_once APPPATH . '/libraries/REST_Controller.php';
class APIv1_Controller extends REST_Controller
{
function __construct()
{
parent::__construct();
$this->load->helper('Message');
}
/** ---------------------------------------------------------------
* Success
*
* @param mixed $retval
* @return array
*/
protected function _success($retval, $message = null)
{
return success($retval, $message);
}
/** ---------------------------------------------------------------
* General Error
*
* @return array
*/
protected function _error($retval, $message = null)
{
return error($retval, $message);
}
/**
*
* @param type $data
* @return typeparses empty string to NULL
*/
protected function _parseData($data)
{
if(is_array($data))
{
foreach($data as $key=>$value)
{
if($value === "")
{
$data[$key] = NULL;
}
}
return $data;
}
elseif(is_object($data))
{
//TODO
}
else
{
if($data == "")
{
return NULL;
}
}
}
}