本文整理汇总了PHP中static::current方法的典型用法代码示例。如果您正苦于以下问题:PHP static::current方法的具体用法?PHP static::current怎么用?PHP static::current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::current方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: current
/**
* Returns the current url with all bells and whistles
*
* @return string
*/
public static function current()
{
if (!is_null(static::$current)) {
return static::$current;
}
return static::$current = static::scheme() . '://' . server::get('HTTP_HOST') . server::get('REQUEST_URI');
}
示例2: setCurrent
public static function setCurrent($locale)
{
if (!isset(static::$registered[$locale])) {
throw new Exception("Locale [{$locale}] is not registered");
}
static::$current = static::$registered[$locale];
}
示例3: getCurrent
public static function getCurrent()
{
if (null === static::$current) {
static::$current = new Request(null);
}
return static::$current;
}
示例4: current
/**
* Returns the current url with all bells and whistles
*
* @return string
*/
public static function current()
{
if (!is_null(static::$current)) {
return static::$current;
}
return static::$current = static::base() . server::get('REQUEST_URI');
}
示例5: current
public static function current()
{
if (static::$current === null) {
static::$current = static::instance('current');
}
return static::$current;
}
示例6: current
/**
* Gets/sets current environment's object
*
* @param $set_current mixed
* @return Current
*/
public static function current($set_current = null)
{
$called_class = get_called_class();
// set current (ignore Reflection_Property : to enable use of @default Class::current)
if ($set_current && !is_a($set_current, Reflection_Property::class)) {
static::$current = $set_current;
if (!is_a($called_class, Plugin::class, true)) {
Session::current()->set($set_current, Builder::current()->sourceClassName($called_class));
}
} elseif (!isset(static::$current)) {
// get current plugin from plugins manager
if (is_a($called_class, Plugin::class, true)) {
if ($called_class === Builder::class) {
static::$current = new Builder();
} else {
$plugin = Session::current()->plugins->get(Builder::current()->sourceClassName($called_class));
if (!isset(static::$current)) {
static::$current = $plugin;
}
}
} else {
static::$current = Session::current()->get($called_class);
}
}
return static::$current;
}
示例7: current
/**
* Get the current uri string
*
* @return string
*/
public static function current()
{
if (is_null(static::$current)) {
static::$current = static::detect();
}
return static::$current;
}
示例8: createInstance
protected static function createInstance()
{
if (static::$current !== null) {
return;
}
static::$current = new RequestItem();
static::$current->populateFromGlobals();
}
示例9: instance
/**
* Returns the current user instance.
*
* @return \WordPress\Model\User\User
*/
public static function instance()
{
if (!isset(static::$current)) {
if (!is_user_logged_in()) {
return null;
}
static::$current = static::forgeObject(wp_get_current_user());
}
return static::$current;
}
示例10: __construct
/**
* MenuItem constructor.
*/
public function __construct($id)
{
$this->id = $id;
if (is_null(static::$current)) {
static::$current = $this;
$this->level(0);
} else {
static::$current = addItem($this);
$this->level(static::$current->level() + 1);
}
}
示例11: getCurrent
/**
* @return Language
*/
public static function getCurrent()
{
if (static::$current === null) {
$languages = self::getLanguageModels();
foreach ($languages as $language) {
if ($language->locale == Yii::$app->language) {
return static::$current = $language;
}
}
}
return static::$current;
}
示例12: Init
protected static function Init()
{
if (static::$initialized) {
return;
}
if (preg_match("#local\$#", $_SERVER['SERVER_NAME'])) {
static::$current = static::DEV;
} else {
static::$current = static::PROD;
}
static::$initialized = true;
}
示例13: set_current
private static function set_current()
{
static::$current = '/' . str_replace(Url::$application, '', URL_CURRENT);
if (is_int(strpos(static::$current, '?'))) {
static::$current = explode('?', static::$current);
unset(static::$current[count(static::$current) - 1]);
static::$current = implode('/', static::$current);
}
if (static::is()) {
static::set_controller_and_action();
}
}
示例14: __construct
public function __construct()
{
static::$current = $this;
$this->logger = new Logger('Order');
$handler = new StreamHandler('php://stdout', Logger::DEBUG);
$handler->setFormatter(new ColoredLineFormatter(null, "[%level_name%] %message% %context% %extra%\n"));
$this->logger->pushHandler($handler);
$this->collection = new Collection($this->logger);
$this->dossier = new Collector();
$this->logger->addDebug('Runtime constructed');
$this->twigLoader = new \Twig_Loader_Filesystem([]);
$this->twigEnvironment = new \Twig_Environment($this->twigLoader);
$function = new \Twig_SimpleFunction('config', function ($name) {
return $this->config->get($name);
});
$this->twigEnvironment->addFunction($function);
}
示例15: resolve
/**
* The resolve function gets the current route object, it initializes the Input capture
* and triggers the required controller based on the route config file.
*
* @return void
* @author Dan Cox
*/
public static function resolve()
{
$route = static::$router->match(static::$request->getPathInfo(), $_SERVER);
Input::init(static::$request->request);
// Load the old input if there
Input::loadOld();
if ($route) {
$params = $route->params;
// Set as the current route;
static::$current = $route;
$action = $params['action'];
unset($params['action']);
$controller = explode('@', $action);
// Load the controller
require_once dirname(__DIR__) . '/controllers/' . $controller[0] . '.php';
$class = new $controller[0]();
call_user_func_array(array($class, $controller[1]), $params);
} else {
// No matching route
throw new \Exception('No matching routes found');
}
}