本文整理汇总了PHP中Router::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::instance方法的具体用法?PHP Router::instance怎么用?PHP Router::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance;
}
示例2: getInstance
public static function getInstance($reset = false)
{
if (null === Router::$instance || $reset) {
Router::$instance = new Router();
}
return Router::$instance;
}
示例3: getInstance
/**
*
* @return Router
*/
public static function getInstance($index)
{
if (!isset(self::$instance)) {
self::$instance = new self($index);
}
return self::$instance;
}
示例4: instance
public static function instance($uri)
{
if (!self::$instance instanceof Router) {
self::$instance = new Router($uri);
}
return self::$instance;
}
示例5: getInstance
/**
* Ensure the Router object is a singleton.
*
* @return Router single instance.
* @author anza
*/
public static function getInstance($registry)
{
if (!self::$instance) {
self::$instance = new Router($registry);
}
return self::$instance;
}
示例6: me
public static function me()
{
if (is_null(self::$instance)) {
self::$instance = new Router();
}
return self::$instance;
}
示例7: __construct
public function __construct($config)
{
$this->_objects['app'] = App::instance();
$this->_objects['router'] = Router::instance();
$this->_objects['inputs'] = Inputs::instance();
$this->_objects['session'] = Session::instance();
$this->_objects['log'] = Log::factory();
if (!isset($this->app->config['database']['redis'][$config['serverId']])) {
$config['serverId'] = 0;
}
$current = $this->app->config['database']['redis'][$config['serverId']];
$current['serverId'] = $config['serverId'];
$this->_objects['db'] = Db::factory($current);
$this->_objects['infoModel'] = new Info_Model($current);
$info = $this->db->info();
$dbs = $this->infoModel->getDbs($info);
if (!isset($current['max_databases'])) {
$databasesConfig = $this->_objects['db']->config('GET', 'databases');
$current['max_databases'] = $databasesConfig['databases'];
}
// Take care of invalid dbId's. If invalid, set to first available database
if (!is_numeric($config['dbId']) || $config['dbId'] < 0 || $config['dbId'] >= $current['max_databases']) {
$config['dbId'] = $dbs[0];
}
$current['newDB'] = !in_array($config['dbId'], $dbs) ? true : false;
$current['database'] = $config['dbId'];
// Extract number of keys
foreach ($dbs as $i) {
if (preg_match('/^keys=([0-9]+),expires=([0-9]+)/', $info["db{$i}"], $matches)) {
$current['dbs'][$i] = array('id' => $i, 'keys' => $matches[1], 'name' => isset($current['dbNames'][$i]) ? $current['dbNames'][$i] : null);
}
}
$this->db->select($current['database']);
$this->app->current = $current;
}
示例8: self
static function &getInstance()
{
if (!self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
示例9: singleton
public static function singleton()
{
if (!isset(self::$instance)) {
$c = __CLASS__;
self::$instance = new $c();
}
return self::$instance;
}
示例10: disconnect
static function disconnect()
{
if (!self::open()) {
return null;
}
self::$instance->disconnect();
self::$instance = null;
}
示例11: __construct
public function __construct()
{
ini_set('output_buffering', 'On');
ini_set('short_open_tag', 'On');
$this->_dir = '../views/';
$this->app = App::instance();
$this->router = Router::instance();
}
示例12: model
static function model($name)
{
Router::instance()->loadModel($name);
//print $x ? '111' : '222';
$className = ucfirst($name) . 'Model';
// print($name);
return new $className();
}
示例13: __construct
public function __construct($config)
{
$this->_objects['app'] = App::instance();
$this->_objects['router'] = Router::instance();
$this->_objects['session'] = Session::instance();
$this->_objects['db'] = Db::factory($config);
$this->_objects['log'] = Log::factory();
}
示例14: assemble_url
/**
* Assemble URL based on a specific route
*
* Supported options:
*
* - url_base (string): base for URL-s, default is an empty string
* - query_arg_separator (string): what to use to separate query string
* arguments, default is '&'
* - anchor (string): name of the URL anchor
*
* @param string $name
* @param array $params
* @param array $options
* @return string
*/
function assemble_url($name, $params = null, $options = null)
{
static $instance;
if ($instance === null) {
$instance =& Router::instance();
}
// if
return $instance->assemble($name, $params, $options);
}
示例15: _getRequest
private static function _getRequest()
{
if (self::$_request === NULL) {
$router = Router::instance();
// TODO: Try to access the previously matched object
self::$_request = $router->match(ANGIE_PATH_INFO, ANGIE_QUERY_STRING);
}
return self::$_request;
}