• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Yaf_Registry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: indexAction

 public function indexAction()
 {
     $sNewCardID = Yaf_Registry::get('config')->newcardid;
     $sOldCardID = Yaf_Registry::get('config')->oldcardid;
     if (!empty($_GET['ccid'])) {
         $ccid = $_GET['ccid'];
     }
     if (strlen($ccid) == 20) {
         $ccid = substr($ccid, 0, 19);
     } else {
         if (strlen($ccid) != 19) {
             throw new Exception("请检查您的ICCID!");
         }
     }
     $cfArr = TZ_Loader::service('UserFlow', 'Flow')->getFlowProductId($ccid);
     if (empty($cfArr)) {
         $this->_view->display("no_info.html");
         die;
         //throw new Exception("该卡不属于747卡!");
     } else {
         $pid = $cfArr['cpid'];
     }
     if (intval($sNewCardID) != $pid && $pid != $sOldCardID) {
         $this->_view->display("no_info.html");
     } else {
         if ($pid == $sOldCardID) {
             header("location:http://app.747.cn");
         } else {
             $this->_view->display('pay.html');
         }
     }
 }
开发者ID:xiaoyueer98,项目名称:app.heimi.com,代码行数:32,代码来源:Pay.php


示例17: routerShutdown

 public function routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
 {
     $config = \Yaf_Registry::get('configarr');
     $dispatcher = Yaf_Dispatcher::getInstance();
     $twig = '';
     // view 放在module 目录里
     if ($request->module == $config['application']['dispatcher']['defaultModule']) {
         $twig = new \Core_Twig(APP_PATH . 'views', $config['twig']);
     } else {
         $twig = new \Core_Twig(APP_PATH . 'modules/' . $request->module . '/views', $config['twig']);
     }
     // url generate
     $twig->twig->addFunction("url", new Twig_Function_Function("Tools_help::url"));
     // 语言对应
     $twig->twig->addFunction("lang", new Twig_Function_Function("Tools_help::lang"));
     // 图片路径
     $twig->twig->addFunction("fbu", new Twig_Function_Function("Tools_help::fbu"));
     // 数字验证
     $twig->twig->addFunction("is_numeric", new Twig_Function_Function("is_numeric"));
     // 处理错误提醒
     $session_key = array('ErrorMessageStop', 'ErrorMessage', 'Message');
     foreach ($session_key as $value) {
         $twig->assign($value, Tools_help::getSession($value));
         Tools_help::setSession($value, '');
     }
     $dispatcher->setView($twig);
 }
开发者ID:haobojunsun,项目名称:d3,代码行数:27,代码来源:Twig.php


示例18: init

 protected function init()
 {
     $this->_config = Yaf_Registry::get('_config')->toArray();
     $this->_request = $this->getRequest();
     $this->getView()->assign(array('_site' => $this->_config['site']));
     // 开始把框架改造成RESTful,并自动加上OPTIONS的返回
     $method = $this->_request->getMethod();
     $action = $this->_request->getActionName();
     if (method_exists($this, $action . 'Action')) {
         // 兼容原方法,如果已经存在xxxAction的时候直接调用,不再进行RESTful,否则ErrorController与forward的时候会出错
         return;
     }
     $allow = array();
     foreach (array('Get', 'Post', 'Put', 'Delete', 'Head', 'Patch') as $v) {
         if (method_exists($this, $action . $v . 'Action')) {
             $allow[] = $v;
         }
     }
     if (empty($allow)) {
         throw new Exception('', 404);
     }
     if ($method == 'OPTIONS') {
         header('allow: ' . strtoupper(implode(' ', $allow)));
         header('content-length: 0');
         exit;
     } else {
         $camelMethod = substr($method, 0, 1) . strtolower(substr($method, 1));
         if (!in_array($camelMethod, $allow)) {
             throw new Exception('', 405);
         }
         // 重新定位到RESTful对应的action上,比如POST方式请求index,则从indexAction变成indexPostAction
         $this->_request->setActionName($action . $camelMethod);
     }
 }
开发者ID:kevin69,项目名称:Yaf-RESTfull-Test,代码行数:34,代码来源:Controller.php


示例19: show

 /**
  * 获取一条数据
  * 
  * @param int   $uid  用户UID,默认为当前登录用户UID
  * 
  * @return array
  */
 public static function show($uid = false)
 {
     !$uid && ($uid = \Yaf_Registry::get('current_uid'));
     $result = parent::show($uid);
     isset($result['data']) && ($result['data'] = self::decodeData($result['data']));
     return $result;
 }
开发者ID:chaoyanjie,项目名称:HiBlog,代码行数:14,代码来源:Blog.php


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Yii类代码示例发布时间:2022-05-23
下一篇:
PHP Yaf_Loader类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap