mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
adds comments for phpdoc
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10770 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
e86bde72e0
commit
7d2e67c9ad
1 changed files with 89 additions and 34 deletions
|
|
@ -1,83 +1,129 @@
|
|||
<?php
|
||||
/**
|
||||
* @class Object
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief Base class design to pass the Object instance between XE Modules
|
||||
* Every modules inherits from Object class. It includes error, message, and other variables for communicatin purpose.
|
||||
*
|
||||
* @remark Every modules inherits from Object class. It includes error, message, and other variables for communicatin purpose
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
**/
|
||||
|
||||
class Object {
|
||||
var $error = 0; // / "Error code (if 0, it is not an error)
|
||||
var $message = 'success'; // / "Error message (if success, it is not an error)
|
||||
|
||||
var $variables = array(); // /< an additional variable
|
||||
var $httpStatusCode = NULL; ///< http status code.
|
||||
|
||||
/**
|
||||
* @brief constructor
|
||||
* Error code. If `0`, it is not an error.
|
||||
* @var int
|
||||
*/
|
||||
var $error = 0;
|
||||
|
||||
/**
|
||||
* Error message. If `success`, it is not an error.
|
||||
* @var string
|
||||
*/
|
||||
var $message = 'success';
|
||||
|
||||
/**
|
||||
* An additional variable
|
||||
* @var array
|
||||
*/
|
||||
var $variables = array();
|
||||
|
||||
/**
|
||||
* http status code.
|
||||
* @var int
|
||||
*/
|
||||
var $httpStatusCode = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $error Error code
|
||||
* @param string $message Error message
|
||||
* @return void
|
||||
**/
|
||||
function Object($error = 0, $message = 'success') {
|
||||
$this->setError($error);
|
||||
$this->setMessage($message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Setter to set error code
|
||||
* @param[in] $error error code
|
||||
* Setter to set error code
|
||||
*
|
||||
* @param int $error error code
|
||||
* @return void
|
||||
**/
|
||||
function setError($error = 0) {
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Getter to retrieve error code
|
||||
* Getter to retrieve error code
|
||||
*
|
||||
* @return int Returns an error code
|
||||
**/
|
||||
function getError() {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter to set HTTP status code
|
||||
*
|
||||
* @param int $code HTTP status code. Default value is `200` that means successful
|
||||
* @return void
|
||||
*/
|
||||
function setHttpStatusCode($code = '200')
|
||||
{
|
||||
$this->httpStatusCode = $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter to retrieve HTTP status code
|
||||
*
|
||||
* @return int Returns HTTP status code
|
||||
*/
|
||||
function getHttpStatusCode()
|
||||
{
|
||||
return $this->httpStatusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Setter to set set the error message
|
||||
* @param[in] $message a messge string
|
||||
* @return return True
|
||||
* @remark this method always returns True. We'd better remove it
|
||||
* Setter to set set the error message
|
||||
*
|
||||
* @param string $message Error message
|
||||
* @return bool Alaways returns true.
|
||||
**/
|
||||
function setMessage($message = 'success') {
|
||||
if(Context::getLang($message)) $message = Context::getLang($message);
|
||||
$this->message = $message;
|
||||
|
||||
// TODO This method always returns True. We'd better remove it
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief getter to retrieve an error message
|
||||
* Getter to retrieve an error message
|
||||
*
|
||||
* @return string Returns message
|
||||
**/
|
||||
function getMessage() {
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief setter to set a key/value pair as an additional variable
|
||||
* @param[in] $key a variable name
|
||||
* @param[in] $val a value for the variable
|
||||
* Setter to set a key/value pair as an additional variable
|
||||
*
|
||||
* @param string $key A variable name
|
||||
* @param mixed $val A value for the variable
|
||||
* @return void
|
||||
**/
|
||||
function add($key, $val) {
|
||||
$this->variables[$key] = $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief method to set multiple key/value pairs as an additional variables
|
||||
* @param[in] $object either object or array containg key/value pairs to be added
|
||||
* Method to set multiple key/value pairs as an additional variables
|
||||
*
|
||||
* @param Object|array $object Either object or array containg key/value pairs to be added
|
||||
* @return void
|
||||
**/
|
||||
function adds($object)
|
||||
{
|
||||
|
|
@ -93,7 +139,10 @@ class Object {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief method to retrieve a corresponding value to a given key
|
||||
* Method to retrieve a corresponding value to a given key
|
||||
*
|
||||
* @param string $key
|
||||
* @return string Returns value to a given key
|
||||
**/
|
||||
function get($key) {
|
||||
return $this->variables[$key];
|
||||
|
|
@ -101,8 +150,9 @@ class Object {
|
|||
|
||||
|
||||
/**
|
||||
* @brief method to retrieve an object containing a key/value paris
|
||||
* @return Returns an object containing key/value pairs
|
||||
* Method to retrieve an object containing a key/value paris
|
||||
*
|
||||
* @return Object Returns an object containing key/value pairs
|
||||
**/
|
||||
function gets() {
|
||||
$num_args = func_num_args();
|
||||
|
|
@ -115,16 +165,18 @@ class Object {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief method to retrieve an array of key/value pairs
|
||||
* @return Return a list of key/value pairs
|
||||
* Method to retrieve an array of key/value pairs
|
||||
*
|
||||
* @return array
|
||||
**/
|
||||
function getVariables() {
|
||||
return $this->variables;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief method to retrieve an object of key/value pairs
|
||||
* @return Return an object of key/value pairs
|
||||
* Method to retrieve an object of key/value pairs
|
||||
*
|
||||
* @return Object
|
||||
**/
|
||||
function getObjectVars() {
|
||||
foreach($this->variables as $key => $val) $output->{$key} = $val;
|
||||
|
|
@ -132,17 +184,20 @@ class Object {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief method to return either true or false depnding on the value in a 'error' variable
|
||||
* @remark this method is misleading in that it returns true if error is 0, which should be true in
|
||||
* boolean representation.
|
||||
* Method to return either true or false depnding on the value in a 'error' variable
|
||||
*
|
||||
* @return bool Retruns true : error isn't 0 or false : otherwise.
|
||||
**/
|
||||
function toBool() {
|
||||
// TODO This method is misleading in that it returns true if error is 0, which should be true in boolean representation.
|
||||
return $this->error==0?true:false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief method to return either true or false depnding on the value in a 'error' variable
|
||||
* Method to return either true or false depnding on the value in a 'error' variable
|
||||
*
|
||||
* @return bool
|
||||
**/
|
||||
function toBoolean() {
|
||||
return $this->toBool();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue