Exemplo n.º 1
0
 /**
  * Sets up Autoloading
  *
  * @param string|array path
  * @return this
  */
 public function setLoader()
 {
     if (!class_exists('Eden_Loader')) {
         //require autoload
         require_once dirname(__FILE__) . '/eden/loader.php';
     }
     //set autoload class as the autoload handler
     spl_autoload_register(array(Eden_Loader::i(), 'handler'));
     //we need Eden_Path to fix the path formatting
     if (!class_exists('Eden_Path')) {
         Eden_Loader::i()->addRoot(dirname(__FILE__))->load('Eden_Path');
     }
     //get paths
     $paths = func_get_args();
     //if no paths
     if (empty($paths)) {
         //do nothing more
         return $this;
     }
     //no dupes
     $paths = array_unique($paths);
     //for each path
     foreach ($paths as $i => $path) {
         if (!is_string($path) && !is_null($path)) {
             continue;
         }
         if ($path) {
             //format the path
             $path = (string) Eden_Path::i($path);
         } else {
             $path = $this->_root;
         }
         //if path is not a real path
         if (!is_dir($path)) {
             //append the root
             $path = $this->_root . $path;
         }
         //if the path is still a real path
         if (is_dir($path)) {
             //add the root
             Eden_Loader::i()->addRoot($path);
         }
     }
     return $this;
 }
Exemplo n.º 2
0
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;}}}
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
 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;
 }