示例#1
0
文件: loop.php 项目: brynner/postr
 /**
  * Hijacks the class and loop through the results
  *
  * @param object
  * @param callable
  * @return this
  */
 public function iterate($scope, $callback)
 {
     Eden_Error::i()->argument(1, 'object')->argument(2, 'callable');
     $this->_scope = $scope;
     $this->_callback = $callback;
     return $this;
 }
示例#2
0
文件: embedly.php 项目: annaqin/eden
 /**
  * Returns Embedly oEmbed Instance
  *
  * @param *string 
  * @param *string 
  * @return Eden_Embedly_Oembed
  */
 public function oembed($key)
 {
     //Argument test
     Eden_Error::i()->argument(1, 'string');
     //Argument 1 must be a string
     return Eden_Embedly_Oembed::i($key);
 }
示例#3
0
 /**
  * Hijacks the class and reports the results of the next
  * method call
  *
  * @param object
  * @param string
  * @return this
  */
 public function next($scope, $name = NULL)
 {
     Eden_Error::i()->argument(1, 'object')->argument(2, 'string', 'null');
     $this->_scope = $scope;
     $this->_name = $name;
     return $this;
 }
示例#4
0
文件: error.php 项目: annaqin/eden
 protected function _isValid($type, $data)
 {
     if ($type == 'gmt') {
         return preg_match('/^GMT(\\-|\\+)[0-9]{2,4}$/', $data);
     }
     return parent::_isValid($type, $data);
 }
示例#5
0
文件: oembed.php 项目: annaqin/eden
 public function __construct($key)
 {
     //argument test
     Eden_Error::i()->argument(1, 'string');
     //Argument 1 must be a string
     $this->_key = $key;
 }
示例#6
0
文件: error.php 项目: brynner/postr
 protected function _isValid($type, $data)
 {
     $valid = Eden_Timezone_Validation::i();
     switch ($type) {
         case 'location':
             return $valid->isLocation($data);
         case 'utc':
             return $valid->isUtc($data);
         case 'abbr':
             return $valid->isAbbr($data);
         default:
             break;
     }
     return parent::_isValid($type, $data);
 }
 private static function _getInstance($class)
 {
     $trace = debug_backtrace();
     $args = array();
     if (isset($trace[1]['args']) && count($trace[1]['args']) > 1) {
         $args = $trace[1]['args'];
         //shift out the class name
         array_shift($args);
     } else {
         if (isset($trace[2]['args']) && count($trace[2]['args']) > 0) {
             $args = $trace[2]['args'];
         }
     }
     if (count($args) === 0 || !method_exists($class, '__construct')) {
         return new $class();
     }
     $reflect = new ReflectionClass($class);
     try {
         return $reflect->newInstanceArgs($args);
     } catch (Reflection_Exception $e) {
         Eden_Error::i()->setMessage(Eden_Error::REFLECTION_ERROR)->addVariable($class)->addVariable('new')->trigger();
     }
 }
示例#8
0
文件: array.php 项目: brynner/postr
 /** 
  * Loops through returned result sets
  *
  * @param *callable
  * @return this
  */
 public function each($callback)
 {
     Eden_Error::i()->argument(1, 'callable');
     foreach ($this->_data as $key => $value) {
         call_user_func($callback, $key, $value);
     }
     return $this;
 }
示例#9
0
文件: error.php 项目: annaqin/eden
 /**
  * In a perfect production environment, 
  * we can assume that arguments passed in
  * all methods are valid. To increase
  * performance call this method.
  *
  * @return this
  */
 public function noArgTest()
 {
     self::$_argumentTest = false;
     return $this;
 }
示例#10
0
文件: block.php 项目: annaqin/eden
 /**
  * For one file Eden, you can set the default
  * location of Eden's template to another location.
  *
  * @param string
  * @return this
  */
 public function setBlockRoot($root)
 {
     Eden_Error::i()->argument(1, 'folder');
     self::$_blockRoot = $root;
     return $this;
 }
示例#11
0
文件: eden.php 项目: annaqin/eden
 /**
  * Sets the PHP timezone
  * 
  * @return this
  */
 public function setTimezone($zone)
 {
     Eden_Error::i()->argument(1, 'string');
     date_default_timezone_set($zone);
     return $this;
 }
示例#12
0
 /**
  * Lets the framework handle exceptions.
  * This is useful in the case that you 
  * use this framework on a server with
  * no xdebug installed.
  *
  * @param string|null the error type to report
  * @param bool|null true will turn debug on
  * @return this
  */
 public function setDebug($reporting = NULL, $default = NULL)
 {
     Eden_Error::i()->argument(1, 'int', 'null')->argument(2, 'bool', 'null');
     Eden_Loader::i()->load('Eden_Template')->Eden_Error_Event()->when(!is_null($reporting), 1)->setReporting($reporting)->when($default === true, 4)->setErrorHandler()->setExceptionHandler()->listen('error', $this, 'error')->listen('exception', $this, 'error')->when($default === false, 4)->releaseErrorHandler()->releaseExceptionHandler()->unlisten('error', $this, 'error')->unlisten('exception', $this, 'error');
     return $this;
 }
示例#13
0
if(!class_exists('Eden_Timezone_Error')){class Eden_Timezone_Error extends Eden_Error{public static function i($message=NULL,$code=0){$class=__CLASS__;return new $class($message,$code);}protected function _isValid($type,$data){$valid=Eden_Timezone_Validation::i();switch($type){case 'location': return $valid->isLocation($data);case 'utc': return $valid->isUtc($data);case 'abbr': return $valid->isAbbr($data);default: break;}return parent::_isValid($type,$data);}}}