本文整理汇总了PHP中static::init方法的典型用法代码示例。如果您正苦于以下问题:PHP static::init方法的具体用法?PHP static::init怎么用?PHP static::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* @return static
*/
public static function get()
{
if (!isset(self::$_instance)) {
self::$_instance = new static();
self::$_instance->init();
}
return self::$_instance;
}
示例2: instance
/**
* @return static
*/
public static function instance()
{
if (null === static::$instance) {
static::$instance = new static();
static::$instance->init();
}
return static::$instance;
}
示例3: init
/**
* 初始化
*/
static function init()
{
if (!isset(static::$init)) {
static::$init = new Static();
}
return static::$init;
}
示例4: init
protected static function init()
{
static::$latin_map[' '] = '-';
static::$latin_map['/'] = '-';
static::$latin_map["'"] = '';
static::$latin_map['&'] = '';
static::$replace_map = array("search" => array_keys(static::$latin_map), "replace" => array_values(static::$latin_map));
static::$init = true;
}
示例5: Initialize
public static function Initialize()
{
static $instance = NULL;
if ($instance === NULL) {
$instance = new static();
$instance->init();
}
return $instance;
}
示例6: getInstance
public static function getInstance($control)
{
if (empty(static::$modules)) {
$_Instance = new static();
if (is_callable(array($_Instance, 'init'))) {
$_Instance->init();
}
static::$modules =& M();
}
return $_Instance;
}
示例7: create
/**
* A method for generating a free-form enum at runtime.
* Simply pass this method a list of values and BAM you have an enum.
* No need for all that class extending nonsense here.
*
* @param string This accepts multiple arguments
* @return Enum instance
*/
public static function create($val)
{
$c = new static();
$c->enum = [];
$c->values = [];
foreach (func_get_args() as $v) {
if (!in_array($v, $c->enum)) {
$c->enum[] = $v;
}
}
$c->init();
return $c;
}
示例8: getById
/**
* @param $post
* @return static
*/
public static function getById($post)
{
$instance = new static($post);
if (is_numeric($post)) {
$instance->id = absint($post);
$instance->post = get_post($instance->id);
} elseif ($post instanceof WA_Project) {
$instance->id = absint($post->id);
$instance->post = $post;
} elseif ($post instanceof WP_Post || isset($post->ID)) {
$instance->id = absint($post->ID);
$instance->post = $post;
}
$instance->init();
return $instance;
}
示例9: init
/**
* Ensure the session data is loaded into cache.
*
* @return void
*/
protected static function init()
{
if (static::$init) {
return;
}
static::$init = true;
if (!static::$name) {
throw new \Exception("Cannot start session, no name has been specified");
}
session_cache_limiter(false);
session_name(static::$name);
session_start();
# Grab the sessions data to respond to get()
static::$data = $_SESSION;
# Remove the lock from the session file
session_write_close();
}
示例10: clearEventsCache
public static function clearEventsCache($iblockId)
{
$ec = new static();
$ec->init(array());
$ec->ClearCache($ec->cachePath . 'events/' . intval($iblockId) . '/');
}
示例11: finalize
public static function finalize()
{
// Make sure the autoloader is initialized
if (!static::isInit()) {
return true;
}
// Unregister the autoloader function
if (spl_autoload_unregister(__CLASS__ . '::loadClass') === false) {
return false;
}
// Clear the list of loaders
static::removeAllLoaders();
// Set the initialization flag, return the result
static::$init = false;
return true;
}
示例12: factory
/**
* Factory
*/
public static function factory()
{
$instance = new static();
$instance->init();
return $instance;
}
示例13: init
/**
* Set core initialization status
*
* @return void
*/
public function init()
{
static::$init = TRUE;
}
示例14: launch
/**
* Launches an app actor
* @param integer $id
* @param callable $handler
* @param array $config
*/
public static function launch($id, callable $handler, array $config = [])
{
$app = new static($id, $handler, $config);
$app->init();
$app->run();
}
示例15: init
/**
* Load settings.
*/
protected static function init()
{
if (!static::$init) {
// Make sure session counting is initialised, even if we don't listen to
// any request init event (conf session_counters).
static::sessionCounters();
// Find real path, and document root (if possible), for removal from
// absolute paths.
// The reason document root may differ from real path is symbolic links.
if ($paths = static::configGet('inspect', 'paths')) {
// Last bucket is path length.
static::$pathLength = array_pop($paths);
static::$paths = $paths;
} else {
$docRoot = '';
$le0 = static::mb_strlen($realPath = static::docRoot());
// getcwd().
$le1 = !empty($_SERVER['SCRIPT_FILENAME']) ? static::mb_strlen($docRoot = dirname($_SERVER['SCRIPT_FILENAME'])) : 0;
// Find longest path.
$osNix = DIRECTORY_SEPARATOR == '/';
// And remove drive C:, for Windows.
static::$pathLength = ($le0 < $le1 ? $le0 : $le1) - ($osNix ? 0 : 2);
static::$paths = $paths = array($osNix ? '/^' . preg_quote($realPath, '/') . '\\//' : '/^(' . $realPath[0] . '\\:)?' . str_replace('/', '[\\\\\\/]', preg_quote(str_replace('\\', '/', static::mb_substr($realPath, 2)))) . '[\\\\\\/]/i');
if ($le1 && $docRoot != $realPath) {
static::$paths[] = $osNix ? '/^' . preg_quote($docRoot, '/') . '\\//' : '/^(' . $docRoot[0] . '\\:)?' . str_replace('/', '[\\\\\\/]', preg_quote(str_replace('\\', '/', static::mb_substr($docRoot, 2)))) . '[\\\\\\/]/i';
}
// Save, they are kind of expensive to establish.
$paths[] = static::$pathLength;
static::configSet('inspect', 'paths', $paths);
}
unset($paths);
// Establish output max length.
static::$outputMax = static::outputMax();
// Establish request time start.
$t = static::requestTimeMilli();
// Establish max execution time abort - if any max at all.
if (static::$maxExecTime = $max = ini_get('max_execution_time')) {
static::$maxExecTimeout = floor($t / 1000) + floor($max * static::configGet('inspect', 'exectime_percent', 90) / 100);
} else {
static::$maxExecTimeout = -1;
}
// Prepare default options - make get options equal file options if CLI
// request.
if (PHP_SAPI === 'cli') {
// Array append.
static::$defaultsByTarget['get'] += static::$defaultsByTarget['file'];
}
static::$init = TRUE;
}
}