改名
This commit is contained in:
@@ -74,7 +74,7 @@ class Component extends BaseObject
|
||||
*/
|
||||
public function trigger($name, $event = null, $params = [], $isRemove = false)
|
||||
{
|
||||
$aEvents = Snowflake::get()->event;
|
||||
$aEvents = Snowflake::app()->event;
|
||||
if (isset($this->_events[$name])) {
|
||||
$events = $this->_events[$name];
|
||||
foreach ($events as $key => $_event) {
|
||||
@@ -98,7 +98,7 @@ class Component extends BaseObject
|
||||
*/
|
||||
public function off($name, $handler = NULL)
|
||||
{
|
||||
$aEvents = Snowflake::get()->event;
|
||||
$aEvents = Snowflake::app()->event;
|
||||
if (!isset($this->_events[$name])) {
|
||||
return $aEvents->of($name, $handler);
|
||||
}
|
||||
@@ -125,7 +125,7 @@ class Component extends BaseObject
|
||||
public function offAll()
|
||||
{
|
||||
$this->_events = [];
|
||||
$aEvents = Snowflake::get()->event;
|
||||
$aEvents = Snowflake::app()->event;
|
||||
$aEvents->clean();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class Config extends Component
|
||||
*/
|
||||
public static function get($key, $try = FALSE, $default = null)
|
||||
{
|
||||
$config = Snowflake::get()->config;
|
||||
$config = Snowflake::app()->config;
|
||||
|
||||
if (strpos($key, '.') === false) {
|
||||
if (isset($config->data[$key])) {
|
||||
@@ -74,7 +74,7 @@ class Config extends Component
|
||||
*/
|
||||
public static function set($key, $value)
|
||||
{
|
||||
$config = Snowflake::get()->config;
|
||||
$config = Snowflake::app()->config;
|
||||
return $config->data[$key] = $value;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class Config extends Component
|
||||
*/
|
||||
public static function has($key, $must_not_null = false)
|
||||
{
|
||||
$config = Snowflake::get()->config;
|
||||
$config = Snowflake::app()->config;
|
||||
if (!isset($config->data[$key])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class Application extends BaseApplication
|
||||
*/
|
||||
public function start()
|
||||
{
|
||||
$manager = Snowflake::get()->server;
|
||||
$manager = Snowflake::app()->server;
|
||||
$manager->start();
|
||||
}
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ class Redis extends Component
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$event = Snowflake::get()->event;
|
||||
$event = Snowflake::app()->event;
|
||||
$event->on(Event::RELEASE_ALL, [$this, 'destroy']);
|
||||
$event->on(Event::EVENT_AFTER_REQUEST, [$this, 'release']);
|
||||
}
|
||||
@@ -296,7 +296,7 @@ class Redis extends Component
|
||||
*/
|
||||
public function release()
|
||||
{
|
||||
$connections = Snowflake::get()->pool->redis;
|
||||
$connections = Snowflake::app()->pool->redis;
|
||||
$connections->release($this->get_config(), true);
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ class Redis extends Component
|
||||
*/
|
||||
public function destroy()
|
||||
{
|
||||
$connections = Snowflake::get()->pool->redis;
|
||||
$connections = Snowflake::app()->pool->redis;
|
||||
$connections->destroy($this->get_config(), true);
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ class Redis extends Component
|
||||
*/
|
||||
public function proxy()
|
||||
{
|
||||
$connections = Snowflake::get()->pool->redis;
|
||||
$connections = Snowflake::app()->pool->redis;
|
||||
|
||||
$config = $this->get_config();
|
||||
$name = $config['host'] . ':' . $config['prefix'] . ':' . $config['databases'];
|
||||
|
||||
@@ -75,7 +75,7 @@ class ErrorHandler extends Component implements ErrorInterface
|
||||
{
|
||||
$this->category = 'exception';
|
||||
|
||||
$event = Snowflake::get()->event;
|
||||
$event = Snowflake::app()->event;
|
||||
$event->trigger(Event::RELEASE_ALL);
|
||||
|
||||
$this->sendError($exception->getMessage(), $exception->getFile(), $exception->getLine());
|
||||
@@ -101,9 +101,9 @@ class ErrorHandler extends Component implements ErrorInterface
|
||||
|
||||
$data = JSON::to(500, 'Error : ' . $error[1], $path);
|
||||
|
||||
Snowflake::get()->getLogger()->error($data, 'error');
|
||||
Snowflake::app()->getLogger()->error($data, 'error');
|
||||
|
||||
$event = Snowflake::get()->event;
|
||||
$event = Snowflake::app()->event;
|
||||
$event->trigger(Event::RELEASE_ALL);
|
||||
|
||||
throw new \ErrorException($error[1], $error[0], 1, $error[2], $error[3]);
|
||||
@@ -123,7 +123,7 @@ class ErrorHandler extends Component implements ErrorInterface
|
||||
|
||||
$data = JSON::to($code, $this->category . ': ' . $message, $path);
|
||||
|
||||
Snowflake::get()->getLogger()->trance($data, $this->category);
|
||||
Snowflake::app()->getLogger()->trance($data, $this->category);
|
||||
|
||||
return response()->send($data);
|
||||
}
|
||||
@@ -154,6 +154,6 @@ class ErrorHandler extends Component implements ErrorInterface
|
||||
*/
|
||||
public function writer($message, $category = 'app')
|
||||
{
|
||||
Snowflake::get()->getLogger()->debug($message, $category);
|
||||
Snowflake::app()->getLogger()->debug($message, $category);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class Logger extends Component
|
||||
public function print_r($message, $category = '')
|
||||
{
|
||||
/** @var Process $logger */
|
||||
$logger = Snowflake::get()->logger;
|
||||
$logger = Snowflake::app()->logger;
|
||||
$logger->write(JSON::encode([$message, $category]));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ class Event extends BaseObject
|
||||
$this->_events[$name] = [];
|
||||
}
|
||||
if ($callback instanceof \Closure) {
|
||||
$callback = \Closure::bind($callback, Snowflake::get());
|
||||
$callback = \Closure::bind($callback, Snowflake::app());
|
||||
} else if (is_array($callback) && is_string($callback[0])) {
|
||||
if (!class_exists($callback[0])) {
|
||||
throw new \Exception('Undefined callback class.');
|
||||
|
||||
+1
-1
@@ -431,7 +431,7 @@ mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY=
|
||||
*/
|
||||
private function getRedis()
|
||||
{
|
||||
return Snowflake::get()->getRedis();
|
||||
return Snowflake::app()->getRedis();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class Pool extends \Snowflake\Abstracts\Pool
|
||||
*/
|
||||
public function getRedis()
|
||||
{
|
||||
return Snowflake::get()->redis_connections;
|
||||
return Snowflake::app()->redis_connections;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ class Pool extends \Snowflake\Abstracts\Pool
|
||||
*/
|
||||
public function getDb()
|
||||
{
|
||||
return Snowflake::get()->connections;
|
||||
return Snowflake::app()->connections;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ class ServerInotify extends Process
|
||||
public function trigger_reload()
|
||||
{
|
||||
/** @var Server $server */
|
||||
$server = Snowflake::get()->get('server')->getServer();
|
||||
$server = Snowflake::app()->get('server')->getServer();
|
||||
$server->reload();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class Snowflake
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public static function get()
|
||||
public static function app()
|
||||
{
|
||||
return static::$service;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user