exit(0); } // Set library directory to php.ini include_path $baseDir = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR); $includePath = get_include_path(); $libPath = $baseDir . DIRECTORY_SEPARATOR . 'library'; if (!is_dir($libPath)) { echo 'Core library could not find in this system.' . PHP_EOL; exit(0); } // If library directory already set in include_path, do not set. if (!preg_match('"' . $libPath . '"', $includePath, $match)) { set_include_path($includePath . PATH_SEPARATOR . $libPath); } // Add app directory $includePath = get_include_path(); $appPath = $baseDir . DIRECTORY_SEPARATOR . 'app'; if (!is_dir($appPath)) { echo 'App directory could not find in this system.' . PHP_EOL; exit(0); } // If app directory already set in include_path, do not set. if (!preg_match('"' . $appPath . '"', $includePath, $match)) { set_include_path($includePath . PATH_SEPARATOR . $appPath); } /** * @see Gene_Base */ require_once 'Gene/Base.php'; Gene_Base::run($appPath);
/** * 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; }
/** * Get dao * * @param mixed $className Model class name * @param mixed $path Path to model * @access public * @throws Gene_Services_Exception * @return Instance of model class */ public function getDao($className, $adapter = 'default') { if (array_key_exists($className, $this->_instances)) { return $this->_instances[$className]; } if (is_null($this->_dbAdapter)) { $db = Gene_Base::getComponent('adapter'); // If database adapter is instance of Zend_Db_Adapter_Abstract, // add to class variable for using transaction. $this->_dbAdapter = $db->getDbAdapter($adapter); } // Create model object. $instance = new $className(); // Set to class variable. $this->_instances[$className] = $instance; return $instance; }