예제 #1
0
파일: Base.php 프로젝트: heavenshell/gene
 /**
  * Setup application
  *
  * @param  mixed $appPath Path to application root
  * @param  array $options Options to setup application
  * @access public
  * @return Zend_Application Application
  */
 public static function app($appPath, array $options = array())
 {
     defined('GENE_APP_PATH') || define('GENE_APP_PATH', $appPath);
     defined('GENE_LIB_PATH') || define('GENE_LIB_PATH', dirname(__FILE__));
     self::$_appPath = GENE_APP_PATH;
     if (!isset($options['ini'])) {
         $options['ini'] = rtrim(GENE_APP_PATH, '\\/') . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.ini';
     }
     if (!isset($options['env'])) {
         $options['env'] = 'production';
     }
     self::$_env = $options['env'];
     require_once 'Zend/Application.php';
     $app = new Zend_Application($options['env'], $options['ini']);
     $autoloader = $app->getAutoloader();
     $autoloader->setFallbackAutoloader(true)->suppressNotFoundWarnings(false);
     $app->getBootstrap()->setAppPath($appPath);
     if (isset($options['config'])) {
         $app->setConfigPath($options['config']);
     }
     $resources = null;
     if (isset($options['resources'])) {
         $resources = $options['resources'];
     }
     $bootstrap = $app->getBootstrap()->bootstrap($resources);
     $params = $bootstrap->getParams();
     self::$_params = $params;
     return $app;
 }