/** * $controller::$configuration['statusKey'] = 'status' by default * $controller::$configuration['statusError'] = 'error' by default * $controller::$configuration['resourceKey'] = 'resource' by default * $controller::$configuration['errorDescriptionKey'] = 'errorDescription' by default * @param string $errorCode is a key of Response::$errorDictionary array. * @param array $errorresource null by default. Can be added to specify error body (resource) of response * @return array prepeared to be JSON encoded */ public static function error($errorCode, $errorresource = null) { $controller = Yii::app()->controller; $errorDescription = self::errorDescription($errorCode); self::$response = array($controller::$configuration['statusKey'] => $controller::$configuration['statusError'], $controller::$configuration['statusError'] => array($controller::$configuration['errorCodeKey'] => $errorCode, $controller::$configuration['errorDescriptionKey'] => $errorDescription, $controller::$configuration['resourceKey'] => $errorresource)); return self::get(); }
public static function __constructStatic() { /** * Default response header */ self::$response = new SymResponse(); self::$response->setCharset("UTF-8"); }
public static function set($type, $response) { if (!in_array($type, self::$response_types)) { echo "Invalid Response Type"; return false; } self::$type = $type; self::$response = $response; return array(self::$type => self::$response); }