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


PHP Yaf_Registry类代码示例

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


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

示例1: linkDb

 /**
  * @param  string mysql database name
  * @return [type]
  */
 public static function linkDb($dbname = "_default")
 {
     if (isset(self::$link[$dbname])) {
         return self::$link[$dbname];
     }
     $config = Yaf_Registry::get('config');
     if (!$config->database->get($dbname)) {
         return false;
     }
     $host = $config->database->get($dbname)->host;
     $port = $config->database->get($dbname)->port;
     $user = $config->database->get($dbname)->username;
     $password = $config->database->get($dbname)->password;
     $name = $config->database->get($dbname)->dbname;
     $charset = isset($config->database->get($dbname)->charset) ? $config->database->get($dbname)->charset : "UTF8";
     try {
         $link_temp = new PDO('mysql:host=' . $host . ';port=' . $port . ';dbname=' . $name . ';charset=' . $charset, $user, $password, $arrayName = array(PDO::ATTR_PERSISTENT => false));
         $link_temp->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
         //PHP5.3.6以下,需禁用仿真预处理,防止注入
         $link_temp->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         self::$link[$dbname] = new FluentPDO($link_temp);
     } catch (Exception $e) {
         self::$link[$dbname] = null;
     }
     if (!self::$link[$dbname]) {
         return false;
     }
     return self::$link[$dbname];
 }
开发者ID:blueseller,项目名称:yaf_sample_framework,代码行数:33,代码来源:DB.php

示例2: run

 /**
  * 实例化调用方法,传递需要的数据到模板
  */
 protected function run()
 {
     $_function_get = 'get_' . $this->class_key;
     #$_class_key = $this->object_code.'_'.$this->class_key;
     #$this->add_data($_class_key,$this->$_function_get());
     #DebugTools::print_r($this->$_function_get());
     if ($this->output == 'html') {
         $dir = Yaf_Registry::get('config')->application->directory . '/widgets/views/';
         $widget_view = new Yaf_View_Simple($dir);
         $widget_view->assign('data', $this->{$_function_get}());
         $widget_view->assign('assist_data', $this->assist_data);
         echo $widget_view->render($this->class_key . '.phtml');
         #DebugTools::print_r($res);
         #Yaf_Loader::getInstance()->import($dir.'/item_condition.phtml');
         #DebugTools::print_r($widget_view);
         /*if (empty($this->view)){$this->view = $this->class_key;}
           $this->render($this->view,array(
               'data'=>$this->$_function_get(),
               'assist_data'=>$this->assist_data
           ));*/
     } else {
         if ($this->output == 'json') {
             $this->output_json($this->{$_function_get}());
         } else {
             if ($this->output == 'array') {
                 $this->output_array($this->{$_function_get}());
             }
         }
     }
 }
开发者ID:zhangjingpu,项目名称:yaf-lib,代码行数:33,代码来源:Widget.php

示例3: startAction

 public function startAction()
 {
     $config = Yaf_Registry::get('monitor_config');
     $dataName = $config['loghandle'][$this->logType]['data'];
     $stepTime = intval($config['loghandle'][$this->logType]['step']);
     $logPersistentService = new Service_Log_Persistent();
     $logApp = $logPersistentService->getAppId();
     foreach ($logApp as $table => $appId) {
         $pid = pcntl_fork();
         if (!$pid) {
             $logDataService = new Service_Log_Data($this->logType, $dataName);
             $dataResult = $logDataService->getWeblog($table, $stepTime);
             if (!$dataResult) {
                 return false;
             }
             $etlModel = Model_Loghandle_Etl_Factory::create($this->logType, 'key');
             $extraData = array('logapp' => $logApp, 'data' => $dataResult, 'table' => $table);
             $transData = $etlModel->transform($extraData);
             $firstData = current($dataResult);
             $time = $firstData['time']->sec;
             $etlModel->load($transData, $time);
             exit;
         }
     }
     return false;
 }
开发者ID:kaka987,项目名称:YoungYaf,代码行数:26,代码来源:Weblog.php

示例4: __construct

 public function __construct()
 {
     $tWeixinarr = Yaf_Registry::get("config")->weixin->default->toArray();
     $this->appId = $tWeixinarr['appID'];
     $this->appSecret = $tWeixinarr['appsecret'];
     $this->token = $tWeixinarr['token'];
 }
开发者ID:tanqinwang,项目名称:test_own,代码行数:7,代码来源:Weixin.php

示例5: startAction

 public function startAction()
 {
     $config = Yaf_Registry::get('monitor_config');
     $dataName = $config['loghandle'][$this->logType]['data'];
     $stepTime = intval($config['loghandle'][$this->logType]['step']);
     $modes = explode(',', $config['loghandle'][$this->logType]['mode']);
     $tables = explode(",", trim($config['mongo'][$this->logType]['tables']));
     $logDataService = new Service_Log_Data($this->logType, $dataName);
     $dataResult = $logDataService->getAccessLog($tables, $stepTime);
     if (!$dataResult) {
         return false;
     }
     $firstData = current($dataResult);
     $time = $firstData['time']->sec;
     $modeNum = count($modes);
     $loghandleEtlParserModel = new Model_Loghandle_Etl_Parser();
     $extractData = $loghandleEtlParserModel->extract($dataResult);
     for ($i = 0; $i < $modeNum; $i++) {
         $pid = pcntl_fork();
         $mode = $modes[$i];
         if (!$pid) {
             $etlModel = Model_Loghandle_Etl_Factory::create($this->logType, $mode);
             $transData = $etlModel->transform($extractData);
             $etlModel->load($transData, $time);
             exit;
         }
     }
     return false;
 }
开发者ID:kaka987,项目名称:YoungYaf,代码行数:29,代码来源:Accesslog.php

示例6: _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

示例7: __construct

 /**
  * @param array $config 配置参数
  * @param $driver 上传驱动 Local-本地上传驱动,FTP-FTP上传驱动
  */
 public function __construct($config = array(), $driver)
 {
     //获取上传配置
     $options = Yaf_Registry::get('uploadbase');
     /* 获取配置 */
     $this->config = array_merge($this->config, $config);
     //上传驱动名称
     $driver = $driver ? $driver : ($this->driver ? $this->driver : $options['type']);
     //生成上传驱动名
     $class = strpos($driver, '\\') ? $driver : ucfirst(strtolower($driver));
     //设置上传驱动
     $this->setDriver($class);
     /* 调整配置,把字符串配置参数转换为数组 begin */
     if (!empty($this->config['mimes'])) {
         if (is_string($this->mimes)) {
             $this->config['mimes'] = explode(',', $this->mimes);
         }
         $this->config['mimes'] = array_map('strtolower', $this->mimes);
     }
     if (!empty($this->config['exts'])) {
         if (is_string($this->exts)) {
             $this->config['exts'] = explode(',', $this->exts);
         }
         $this->config['exts'] = array_map('strtolower', $this->exts);
     }
     /* 调整配置,把字符串配置参数转换为数组 end */
 }
开发者ID:huangbinzd,项目名称:yaf_private_test,代码行数:31,代码来源:Upload.php

示例8: __call

 public function __call($func, $args)
 {
     if (false == \Yaf_Registry::has($func)) {
         return $this->loadModule($func, $args[0]);
     }
     return \Yaf_Registry::get($func);
 }
开发者ID:jixiaod,项目名称:yaf-swoole-framework,代码行数:7,代码来源:Yaf.php

示例9: __construct

 public function __construct()
 {
     $this->table = new swoole_table(1024);
     $this->table->column('serverfd', swoole_table::TYPE_INT, 8);
     $this->table->create();
     define('APPLICATION_PATH', dirname(dirname(__DIR__)) . "/application");
     define('MYPATH', dirname(APPLICATION_PATH));
     $this->application = new Yaf_Application(dirname(APPLICATION_PATH) . "/conf/application.ini");
     $this->application->bootstrap();
     $config_obj = Yaf_Registry::get("config");
     $distributed_config = $config_obj->distributed->toArray();
     $server = new swoole_server($distributed_config['ServerIp'], $distributed_config['port'], SWOOLE_PROCESS, SWOOLE_SOCK_TCP);
     if (isset($distributed_config['logfile'])) {
         $server->set(array('worker_num' => 4, 'task_worker_num' => 4, 'dispatch_mode' => 4, 'daemonize' => true, 'log_file' => $distributed_config['logfile']));
     } else {
         $server->set(array('worker_num' => 4, 'task_worker_num' => 4, 'dispatch_mode' => 4, 'daemonize' => true));
     }
     require_once __DIR__ . "/DistributedClient.php";
     $server->on('Start', array(&$this, 'onStart'));
     $server->on('WorkerStart', array(&$this, 'onWorkerStart'));
     $server->on('Connect', array(&$this, 'onConnect'));
     $server->on('Receive', array(&$this, 'onReceive'));
     $server->on('Task', array(&$this, 'onTask'));
     $server->on('Finish', array(&$this, 'onFinish'));
     $server->on('Close', array(&$this, 'onClose'));
     $server->on('ManagerStop', array(&$this, 'onManagerStop'));
     $server->on('WorkerError', array(&$this, 'onWorkerError'));
     $server->start();
 }
开发者ID:qieangel2013,项目名称:zys,代码行数:29,代码来源:DistributedServer.php

示例10: __construct

 public function __construct()
 {
     $this->_config = Yaf_Registry::get("config");
     $this->_db = new Db_Mysql($this->_config->database->config->toArray());
     //$this->_redis = new Redis();
     //$this->_redis->connect($this->_config->redis->host);
 }
开发者ID:zhangxinvip,项目名称:YafUse,代码行数:7,代码来源:Base.php

示例11: getTransport

 private static function getTransport()
 {
     $_config = Yaf_Registry::get("config");
     self::$_cfg = $_config->mail->smtp->toArray();
     self::$_transport = Swift_SmtpTransport::newInstance(self::$_cfg['service'], 25)->setUsername(self::$_cfg['username'])->setPassword(self::$_cfg['password']);
     self::$_mailer = Swift_Mailer::newInstance(self::$_transport);
 }
开发者ID:musicsnap,项目名称:Cdoco_Yaf_Ext,代码行数:7,代码来源:Mail.php

示例12: 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

示例13: init

 /**
  * (non-PHPdoc)
  * @see Yaf_Controller_Abstract::init()
  */
 public function init()
 {
     //判断用户是否登录
     if ($this->_need_login && !Yaf_Registry::get('current_uid')) {
         throw new \Exception\Nologin('no login');
     }
 }
开发者ID:chaoyanjie,项目名称:HiBlog,代码行数:11,代码来源:Abs.php

示例14: init

 public function init()
 {
     parent::init();
     $this->_layout = new LayoutPlugin('layout.html');
     $this->dispatcher = Yaf_Registry::get("dispatcher");
     $this->dispatcher->registerPlugin($this->_layout);
 }
开发者ID:zhangxinvip,项目名称:YafUse,代码行数:7,代码来源:Main.php

示例15: _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


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