Ejemplo n.º 1
0
 /**
  * Constructor.
  *
  * Supported params for $config are:
  * - db              = user-supplied instance of database connector,
  *                     or key name of registry instance.
  * - name            = table name.
  * - primary         = string or array of primary key(s).
  * - rowClass        = row class name.
  * - rowsetClass     = rowset class name.
  * - referenceMap    = array structure to declare relationship
  *                     to parent tables.
  * - dependentTables = array of child tables.
  * - metadataCache   = cache for information from adapter describeTable().
  *
  * @param  mixed $config Array of user-specified config options, or just the Db Adapter.
  * @return void
  */
 public function __construct($config = array())
 {
     if (is_null(self::getDefaultAdapter())) {
         $config_db = Zood_Config::get('db');
         $config_db_option = $config_db['default'];
         $dbAdapter = Zend_Db::factory($config_db_option['adapter'], $config_db_option);
         self::setDefaultAdapter($dbAdapter);
     }
     parent::__construct($config);
 }
Ejemplo n.º 2
0
 /**
  * Get instance
  * 
  * @param string $name
  * @param array $config
  * @return Zend_Cache_Core|Zend_Cache_Frontend
  */
 public static function getInstance($name = 'default', $config = NULL)
 {
     if (isset(self::$_instances[$name])) {
         return self::$_instances[$name];
     }
     if (!is_null($config)) {
         $config = array_merge(Zood_Config::get('cache/' . $name), $config);
     } else {
         $config = Zood_Config::get('cache/' . $name);
     }
     self::$_instances[$name] = self::factory($config['frontend'], $config['backend'], $config['frontendOption'], $config['backendOption']);
     return self::$_instances[$name];
 }
Ejemplo n.º 3
0
 /**
  * Process result data controller action returned
  * 
  * @param array $rs
  * @param Zood_Controller_Action $action
  */
 public function process(array $rs, Zood_Controller_Action $action)
 {
     $this->setData($action->getData());
     $scriptPath = $this->getScriptPath();
     if (empty($scriptPath)) {
         /** Zood_Config */
         require_once 'Zood/Config.php';
         $viewConfig = Zood_Config::get('view');
         if (isset($viewConfig['script_path'])) {
             $scriptPath = $viewConfig['script_path'];
             $this->setScriptPath($scriptPath);
         }
     }
     $script = $this->getScript($rs['resource']);
     $this->render($script);
 }
Ejemplo n.º 4
0
 */
Zood_Loader::registerAutoload();
//require_once 'Zend/Registry.php';
//require_once 'Zood/Util.php';
//require_once 'Zood/Controller/Front.php';
/**
 * Set default configuration dir
 */
//Zood_Loader::loadClass('Zood_Config');
Zood_Config::getInstance()->addConfigDirectory(ZOODPP_APP . '/config');
/**
 * Set default db adapter
 */
//Zood_Loader::loadClass('Zend_Db');
//Zood_Loader::loadClass('Zood_Db_Table_Abstract');
$config_db = Zood_Config::getInstance()->get('db');
$config_db_option = $config_db['master'];
unset($config_db_option['adapter'], $config_db_option['prefix'], $config_db_option['charset'], $config_db_option['showdebug']);
$dbAdapter = Zend_Db::factory($config_db['master']['adapter'], $config_db_option);
$dbAdapter->query('SET NAMES "UTF8";');
Zood_Db_Table_Abstract::setDefaultAdapter($dbAdapter);
//Access authentication
require_once ZOODPP_ROOT . '/app/lib/access/ActionAccessInterceptor.php';
Zood_Controller_Action::addInterceptor(new ActionAccessInterceptor(), 'access');
/**
 * Get front controller instance, set controller dir and dispatch
 */
try {
    Zood_Controller_Front::getInstance()->setBaseUrl()->setControllerDirectory(ZOODPP_APP . '/controllers')->dispatch();
} catch (Exception $e) {
    Zood_Util::print_r($e->getMessage(), 'Exception!');