/** * 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; }
/** * 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; }
/** * 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); }
public function __construct($key) { //argument test Eden_Error::i()->argument(1, 'string'); //Argument 1 must be a string $this->_key = $key; }
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(); } }
/** * 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; }
/** * 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; }
/** * Sets the PHP timezone * * @return this */ public function setTimezone($zone) { Eden_Error::i()->argument(1, 'string'); date_default_timezone_set($zone); return $this; }
/** * 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; }
if(!class_exists('Eden')){function eden(){$class=Eden::i();if(func_num_args()==0){return $class;}$args=func_get_args();return $class->__invoke($args);}class Eden extends Eden_Event{protected $_root=NULL;protected static $_active=NULL;public static function i(){return self::_getSingleton(__CLASS__);}public function __construct(){if(!self::$_active){self::$_active=$this;}$this->_root=dirname(__FILE__);}public function __call($name,$args){try{return parent::__call($name,$args);}catch(Eden_Route_Exception $e){return parent::__call('Eden_'.$name,$args);}}public function setRoot($root){Eden_Error::i()->argument(1,'string');if(!class_exists('Eden_Path')){Eden_Loader::i()->load('Eden_Path');}$this->_root=(string) Eden_Path::i($root);return $this;}public function getRoot(){return $this->_root;}public function getActiveApp(){return self::$_active;}public function setLoader(){if(!class_exists('Eden_Loader')){require_once dirname(__FILE__).'/eden/loader.php';}spl_autoload_register(array(Eden_Loader::i(),'handler'));if(!class_exists('Eden_Path')){Eden_Loader::i()->addRoot(dirname(__FILE__))->load('Eden_Path');}$paths=func_get_args();if(empty($paths)){return $this;}$paths=array_unique($paths);foreach($paths as $i=>$path){if(!is_string($path) && !is_null($path)){continue;}if($path){$path=(string) Eden_Path::i($path);}else{$path=$this->_root;}if(!is_dir($path)){$path=$this->_root.$path;}if(is_dir($path)){Eden_Loader::i()->addRoot($path);}}return $this;}public function routeClasses($routes){Eden_Error::i()->argument(1,'string','array','bool');$route=Eden_Route::i()->getClass();if($routes===true){$route->route('Cache','Eden_Cache')->route('Registry','Eden_Registry')->route('Model','Eden_Model')->route('Collection','Eden_Collection')->route('Cookie','Eden_Cookie')->route('Session','Eden_Session')->route('Template','Eden_Template')->route('Curl','Eden_Curl')->route('Event','Eden_Event')->route('Path','Eden_Path')->route('File','Eden_File')->route('Folder','Eden_Folder')->route('Image','Eden_Image')->route('Mysql','Eden_Mysql')->route('Type','Eden_Type');return $this;}if(is_string($routes)){$routes=include($routes);}foreach($routes as $alias=>$class){$route->route($alias,$class);}return $this;}public function routeMethods($routes){Eden_Error::i()->argument(1,'string','array','bool');$route=Eden_Route::i()->getMethod();if(is_bool($routes)){$route->route(NULL,'output','Eden_Debug');return $this;}if(is_string($routes)){$routes=include($routes);}foreach($routes as $method=>$routePath){if(is_string($routePath)){$routePath=array($routePath);}if(is_array($routePath) && !empty($routePath)){if(count($routePath)==1){$routePath[]=$method;}$route->route($method,$routePath[0],$routePath[1]);}}return $this;}public function startSession(){Eden_Session::i()->start();return $this;}public function setTimezone($zone){Eden_Error::i()->argument(1,'string');date_default_timezone_set($zone);return $this;}}}