当前位置: 首页>>代码示例>>PHP>>正文


PHP Yaf_Registry::set方法代码示例

本文整理汇总了PHP中Yaf_Registry::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Yaf_Registry::set方法的具体用法?PHP Yaf_Registry::set怎么用?PHP Yaf_Registry::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Yaf_Registry的用法示例。


在下文中一共展示了Yaf_Registry::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _initDefaultDbAdapter

 public function _initDefaultDbAdapter()
 {
     //新建对象
     $dbAdapter = new Zend\Db\Adapter\Adapter(Yaf_Application::app()->getConfig()->mysql->write->toArray());
     //设为全局变量
     Yaf_Registry::set("db", $dbAdapter);
 }
开发者ID:nameNotNull,项目名称:Yaf_zendDb,代码行数:7,代码来源:bootstrap.php

示例2: _init

 public function _init(Yaf_Dispatcher $dispatcher)
 {
     // auto start session
     Yaf_Session::getInstance()->start();
     // auto load config data
     $this->config = Yaf_Application::app()->getConfig();
     Yaf_Registry::set('Config', $this->config);
     //auto load redis
     $redis = new Redis();
     $redis->connect($this->config->redis->host, $this->config->redis->port, $this->config->redis->timeout, $this->config->redis->reserved, $this->config->redis->interval);
     Yaf_Registry::set('Redis', $redis);
     //auto load mysql
     Yaf_Registry::set('DbRead', new Db('mysql:host=' . $this->config->mysql->read->host . ';dbname=' . $this->config->mysql->read->dbname . ';charset=' . $this->config->mysql->read->charset . ';port=' . $this->config->mysql->read->port . '', $this->config->mysql->read->username, $this->config->mysql->read->password));
     Yaf_Registry::set('DbWrite', new Db('mysql:host=' . $this->config->mysql->write->host . ';dbname=' . $this->config->mysql->write->dbname . ';charset=' . $this->config->mysql->write->charset . ';port=' . $this->config->mysql->write->port . '', $this->config->mysql->write->username, $this->config->mysql->write->password));
     // auto load model
     Yaf_Registry::set('I18n', new I18nModel($redis, $this->config->application->name, 'cn'));
     Yaf_Registry::set('Cache', new CacheModel($redis, $this->config->application->name));
     // auto load plugin
     $dispatcher->registerPlugin(new GlobalPlugin());
     // auto save request
     $request = $dispatcher->getRequest();
     // auto set ajax is no render
     if ($request->isXmlHttpRequest()) {
         $dispatcher->autoRender(false);
     }
     // auto set http protocol to action except http get protocol
     if (!$request->isGet()) {
         $dispatcher->setDefaultAction($request->getMethod());
     }
 }
开发者ID:a707937337,项目名称:helloword,代码行数:30,代码来源:Bootstrap.php

示例3: loadDatabase

 protected function loadDatabase($name)
 {
     $database = Yaf_Registry::get('_database');
     if (isset($database[$name])) {
         return $database[$name];
     }
     $config = Yaf_Registry::get('_config');
     if (isset($config->database->{$name})) {
         if (is_null($database)) {
             $database = array();
         }
         $dbConfig = $config->database->{$name};
         $pdoParams = array();
         if ($dbConfig->pconnect) {
             $pdoParams[Db::ATTR_PERSISTENT] = TRUE;
         }
         try {
             $conn = new Db($dbConfig->type . ':host=' . $dbConfig->host . '; dbname=' . $dbConfig->database, $dbConfig->username, $dbConfig->password, $pdoParams);
         } catch (PDOException $error) {
             throw new Exception($error->getMessage(), 500);
         }
         $database[$name] = $conn;
         Yaf_Registry::set('_database', $database);
         return $conn;
     } else {
         throw new Exception('Undefined database', 500);
     }
 }
开发者ID:kevin69,项目名称:Yaf-RESTfull-Test,代码行数:28,代码来源:Model.php

示例4: init

 /**
  * Controller的init方法会被自动首先调用
  */
 public function init()
 {
     //调试mysql
     if (isset($_GET['debug6429360'])) {
         $this->debug = true;
         DB_Mysqli::$DEBUG = 1;
     }
     $this->platform = isset($_REQUEST['platform']) ? $_REQUEST['platform'] : $this->platform;
     Yaf_Registry::set("platform", $this->platform);
     $this->isMobile = $this->platform == 'ios' || $this->platform == 'android';
     $this->wap = !$this->isMobile && Common_Mobile::isMobile();
     $this->uid = $this->get('uid', $this->post('uid', false));
     $this->controllerName = $this->getRequest()->getControllerName();
     $this->actionName = $this->getRequest()->getActionName();
     $userModel = new UserModel();
     /*        if (!isset(Common_Config::$NotNeedLogin[$this->controllerName][$this->actionName])
                 && $this->isMobile 
                 && $this->needLogin 
                 && !$this->debug) 
             {
                 $token = $this->get("token", $this->post("token", false));
                 if (!$token) {
                     $this->redirect(NULL, Common_Error::ERROR_TOKEN_NOT_EXISTS);
                 }
     
                 $api = $this->getRequestApi();
                 $check = Common_Token::check($token, $this->uid, strtolower($api));
                 if (!$check) {          
                     $this->redirect(NULL, Common_Error::ERROR_TOKEN);
                 }
             }*/
     $this->uid = $this->uid ? $this->uid : $userModel->getUid();
     /**
      * 如果是Ajax请求, 则关闭HTML输出
      */
     if ($this->getRequest()->isXmlHttpRequest() || 'POST' == $this->getRequest()->getMethod()) {
         $this->ajax = true;
         Yaf_Dispatcher::getInstance()->disableView();
     } else {
         //$path = $this->getView()->getScriptPath();
         //$path[0] = $path[0] . "/" . strtolower($this->getRequest()->getControllerName());
         //$this->getView()->setScriptPath($path[0]);
     }
     //print_r($this->uid?$this->uid:"null");
     //验证登录
     /*if (
                 !isset(Common_Config::$NotNeedLogin[$this->controllerName][$this->actionName]) 
                 && $this->needLogin 
                 && !$this->uid) {
                 $this->redirect("/user/login?from=" . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ""), Common_Error::ERROR_USER_NOT_LOGIN);
     
                 $this->redirect("/user/verify", Common_Error::ERROR_USER_NOT_LOGIN);
             }*/
     //用户信息
     /*        if($this->uid) {
                 $user = $userModel->getUser($this->uid);
                 $this->assign("uInfo", $user);
                 Yaf_Registry::set("uid", $this->uid);
             }*/
 }
开发者ID:krisrita,项目名称:udo,代码行数:63,代码来源:Contr.php

示例5: _initDatabase

 public function _initDatabase()
 {
     $servers = array();
     $database = $this->config->database;
     $servers[] = $database->master->toArray();
     $slaves = $database->slaves;
     if (!empty($slaves)) {
         $slave_servers = explode('|', $slaves->servers);
         $slave_users = explode('|', $slaves->users);
         $slave_passwords = explode('|', $slaves->passwords);
         $slave_databases = explode('|', $slaves->databases);
         $slaves = array();
         foreach ($slave_servers as $key => $slave_server) {
             if (isset($slave_users[$key]) && isset($slave_passwords[$key]) && isset($slave_databases[$key])) {
                 $slaves[] = array('server' => $slave_server, 'user' => $slave_users[$key], 'password' => $slave_passwords[$key], 'database' => $slave_databases[$key]);
             }
         }
         $servers[] = $slaves[array_rand($slaves)];
     }
     Yaf_Registry::set('database', $servers);
     if (isset($database->mysql_cache_enable) && $database->mysql_cache_enable && !defined('MYSQL_CACHE_ENABLE')) {
         define('MYSQL_CACHE_ENABLE', true);
     }
     if (isset($database->mysql_log_error) && $database->mysql_log_error && !defined('MYSQL_LOG_ERROR')) {
         define('MYSQL_LOG_ERROR', true);
     }
     Yaf_Loader::import(APPLICATION_PATH . '/library/Db/Db.php');
     Yaf_Loader::import(APPLICATION_PATH . '/library/Db/DbQuery.php');
 }
开发者ID:liu33851861,项目名称:CZD_Yaf_Extension,代码行数:29,代码来源:Bootstrap.php

示例6: init

 public static function init()
 {
     $_ENV['APP_NAME'] = pathinfo(realpath(APPLICATION_PATH), PATHINFO_BASENAME);
     $configurePath = sprintf('%s/../config/config.ini', APPLICATION_PATH);
     $config = new Yaf_Config_Ini($configurePath, 'production');
     Yaf_Registry::set('dbconfig', $config);
     self::loadEssentials();
 }
开发者ID:YexuanGuo,项目名称:php-cms,代码行数:8,代码来源:SystemConfig.php

示例7: _initZendDb

 public function _initZendDb(Yaf_Dispatcher $dispatcher)
 {
     $arrConfig = Yaf_Application::app()->getConfig();
     $zendDb = new Zend_Db();
     $params = array('host' => $arrConfig->mysql->read->host, 'username' => $arrConfig->mysql->read->username, 'password' => $arrConfig->mysql->read->password, 'dbname' => $arrConfig->mysql->read->dbname, 'port' => $arrConfig->mysql->read->port);
     $db = $zendDb->factory('PDO_MYSQL', $params);
     Yaf_Registry::set('db', $db);
 }
开发者ID:nameNotNull,项目名称:Yaf_Smarty_for_SAE,代码行数:8,代码来源:Bootstrap.php

示例8: _initPlugin

 public function _initPlugin(Yaf_Dispatcher $dispatcher)
 {
     $router = new RouterPlugin();
     $dispatcher->registerPlugin($router);
     $admin = new AdminPlugin();
     $dispatcher->registerPlugin($admin);
     Yaf_Registry::set('adminPlugin', $admin);
 }
开发者ID:xinuxZ,项目名称:YOF,代码行数:8,代码来源:Bootstrap.php

示例9: _initConfig

 public function _initConfig()
 {
     Yaf_Dispatcher::getInstance()->autoRender(FALSE);
     // 关闭自动加载模板
     //把配置保存起来
     $arrConfig = Yaf_Application::app()->getConfig();
     Yaf_Registry::set('config', $arrConfig);
 }
开发者ID:blueseller,项目名称:yaf_sample_framework,代码行数:8,代码来源:Bootstrap.php

示例10: _initRedis

 /**
  * Init Redis
  */
 public function _initRedis(Yaf_Dispatcher $dispatcher)
 {
     $config = Yaf_Application::app()->getConfig();
     $redis = new Redis();
     $redis->connect($config['redis_host'], $config['redis_port']);
     Yaf_Registry::set('redis', $redis);
     // TODO sms Redis queue
     //Yaf_Registry::set('redis_queue_sms', $config['redis_queue_sms']);
 }
开发者ID:GobYang,项目名称:thaidh,代码行数:12,代码来源:Bootstrap.php

示例11: _initConfig

 public function _initConfig(Yaf_Dispatcher $dispatcher)
 {
     $config = Yaf_Application::app()->getConfig();
     Yaf_Registry::set("config", $config);
     $sysConfig = (include APP_PATH . "/conf/config.php");
     Yaf_Registry::set("sysConfig", $sysConfig);
     $dispatcher->autoRender(FALSE);
     //全局关闭渲染
 }
开发者ID:sean0402,项目名称:yarf-framework,代码行数:9,代码来源:Bootstrap.php

示例12: __construct

 public function __construct()
 {
     $this->__application = Yaf_Registry::get('Application');
     if ($this->__application == null) {
         $this->__application = new Yaf_Application(ROOT_PATH . "/conf/application.ini");
         Yaf_Registry::set('Application', $this->__application);
         Yaf_Registry::set('config', $this->__application->getConfig());
     }
 }
开发者ID:guoyu07,项目名称:yaf-phpunit,代码行数:9,代码来源:TestController.php

示例13: _initView

 public function _initView(Yaf_Dispatcher $dispatcher)
 {
     //在这里注册自己的view控制器,例如smarty,firekylin
     $smarty = new Smarty_Adapter(null, Yaf_Registry::get("config")->get("smarty"));
     Yaf_Registry::set("smarty", $smarty);
     $dispatcher->setView($smarty);
     //Yaf_Dispatcher::getInstance()->disableView();
     //var_dump('sssss');
 }
开发者ID:hexing-w,项目名称:flower-yaf,代码行数:9,代码来源:Bootstrap.php

示例14: _initSession

 /**
  * 初始化SESSION
  * 
  * @param Yaf_Dispatcher $dispatcher
  */
 public function _initSession(Yaf_Dispatcher $dispatcher)
 {
     //开启SESSION
     session_name('GITHUBLOG_SID');
     session_start();
     //获取用户UID
     $uid = \Comm\Arg::session('uid', FILTER_VALIDATE_INT);
     Yaf_Registry::set('current_uid', $uid);
 }
开发者ID:chaoyanjie,项目名称:HiBlog,代码行数:14,代码来源:Bootstrap.php

示例15: getAPPConfig

 private function getAPPConfig()
 {
     $key = __METHOD__;
     $config = Yaf_Registry::get($key);
     if ($config == null) {
         $config = Yaf_Application::app() == null ? new Yaf_Application(APPLICATION_CONFIG_PATH . '/application.ini') : Yaf_Application::app();
         Yaf_Registry::set($key, $config);
     }
     return $config;
 }
开发者ID:hzh123,项目名称:my_yaf,代码行数:10,代码来源:SystemConfig.php


注:本文中的Yaf_Registry::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。