本文整理汇总了PHP中Yaf_Registry::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Yaf_Registry::get方法的具体用法?PHP Yaf_Registry::get怎么用?PHP Yaf_Registry::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Yaf_Registry
的用法示例。
在下文中一共展示了Yaf_Registry::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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}());
}
}
}
}
示例2: 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);
}
示例3: __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 */
}
示例4: __call
public function __call($func, $args)
{
if (false == \Yaf_Registry::has($func)) {
return $this->loadModule($func, $args[0]);
}
return \Yaf_Registry::get($func);
}
示例5: __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();
}
示例6: __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);
}
示例7: 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);
}
示例8: 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);
}
}
示例9: 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');
}
}
示例10: init
public function init()
{
parent::init();
$this->_layout = new LayoutPlugin('layout.html');
$this->dispatcher = Yaf_Registry::get("dispatcher");
$this->dispatcher->registerPlugin($this->_layout);
}
示例11: __construct
public function __construct()
{
$tWeixinarr = Yaf_Registry::get("config")->weixin->default->toArray();
$this->appId = $tWeixinarr['appID'];
$this->appSecret = $tWeixinarr['appsecret'];
$this->token = $tWeixinarr['token'];
}
示例12: 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;
}
示例13: loadConfig
public static function loadConfig()
{
if (self::$isLoaded) {
return;
}
$globalConfig = Yaf_Registry::get('config');
if (!isset($globalConfig->log)) {
self::$enableLog = false;
return;
}
$globalLogConfig = $globalConfig->log;
if (isset($globalLogConfig->enable)) {
self::$enableLog = $globalLogConfig->enable;
}
if (isset($globalLogConfig->log_level)) {
self::$logLevel = self::$LOG_LEVELS[$globalLogConfig->log_level];
}
if (!is_string($globalLogConfig->target)) {
$tmpTarget = [];
foreach ($globalLogConfig->target as $k => $v) {
$k = strtoupper($k);
$tmpTarget[$k] = $v;
}
self::$target = $tmpTarget;
} else {
self::$target = ['DEFAULT' => $globalLogConfig->target];
}
self::$isLoaded = true;
}
示例14: indexAction
public function indexAction()
{
//默认Action
//test db library
$dbObj = new Db_Table(SAE_MYSQL_DB, 'user');
$res = $dbObj->getCount('id=3');
var_dump($res);
$field = array();
$whereArr = array('order' => 'id', 'limit' => '3');
$res = $dbObj->getAll($field, $whereArr);
var_dump($res);
//test smarty library
$this->getView()->assign("contentaa", "Hello Worldssss");
//test zendDb library
$db = Yaf_Registry::get('db');
$sql = $db->quoteInto('select * from usertest where user_id <?', '3');
$result = $db->query($sql);
$res = $result->fetchAll();
var_dump($res);
/*
$adapter = new Zend_Db_Table();
$adapter->setDefaultAdapter($db);
$obj = new UserTableModel();
$data = array(
'id' => '1',
'name' => 'King',
'author' => 'Arthur',
'color' => 'blue'
);
$obj->insert($data);*/
}
示例15: 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;
}