改名
This commit is contained in:
@@ -173,7 +173,7 @@ abstract class BaseApplication extends Service
|
||||
if (!isset($config['events']) || !is_array($config['events'])) {
|
||||
return;
|
||||
}
|
||||
$event = Snowflake::app()->event;
|
||||
$event = Snowflake::app()->getEvent();
|
||||
foreach ($config['events'] as $key => $value) {
|
||||
if (is_string($value)) {
|
||||
if (!class_exists($value)) {
|
||||
|
||||
@@ -76,7 +76,7 @@ class Component extends BaseObject
|
||||
*/
|
||||
public function trigger($name, $event = null, $params = [], $isRemove = false)
|
||||
{
|
||||
$aEvents = Snowflake::app()->event;
|
||||
$aEvents = Snowflake::app()->getEvent();
|
||||
if (isset($this->_events[$name])) {
|
||||
$events = $this->_events[$name];
|
||||
foreach ($events as $key => $_event) {
|
||||
@@ -100,7 +100,7 @@ class Component extends BaseObject
|
||||
*/
|
||||
public function off($name, $handler = NULL): void
|
||||
{
|
||||
$aEvents = Snowflake::app()->event;
|
||||
$aEvents = Snowflake::app()->getEvent();
|
||||
if (!isset($this->_events[$name])) {
|
||||
$aEvents->of($name, $handler);
|
||||
return;
|
||||
@@ -129,7 +129,7 @@ class Component extends BaseObject
|
||||
public function offAll()
|
||||
{
|
||||
$this->_events = [];
|
||||
$aEvents = Snowflake::app()->event;
|
||||
$aEvents = Snowflake::app()->getEvent();
|
||||
$aEvents->clean();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Snowflake\Cache;
|
||||
|
||||
use Exception;
|
||||
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Swoole\Coroutine\System;
|
||||
|
||||
@@ -86,7 +87,7 @@ class File extends Component implements ICache
|
||||
/**
|
||||
* @param string $key
|
||||
* @param string $hashKey
|
||||
* @return string|int|bool
|
||||
* @return string|int|bool|null
|
||||
*/
|
||||
public function hGet(string $key, string $hashKey): string|int|bool|null
|
||||
{
|
||||
@@ -119,7 +120,7 @@ class File extends Component implements ICache
|
||||
* @param $key
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($key): bool
|
||||
#[Pure] public function exists($key): bool
|
||||
{
|
||||
return file_exists($key);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class Redis extends Component
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$event = Snowflake::app()->event;
|
||||
$event = Snowflake::app()->getEvent();
|
||||
$event->on(Event::RELEASE_ALL, [$this, 'destroy']);
|
||||
$event->on(Event::EVENT_AFTER_REQUEST, [$this, 'release']);
|
||||
$event->on(Event::SERVER_WORKER_START, [$this, 'createPool']);
|
||||
@@ -46,10 +46,11 @@ class Redis extends Component
|
||||
|
||||
/**
|
||||
* @throws ConfigException
|
||||
* @throws ComponentException
|
||||
*/
|
||||
public function createPool()
|
||||
{
|
||||
$connections = Snowflake::app()->pool->redis;
|
||||
$connections = Snowflake::app()->getPool()->getRedis();
|
||||
|
||||
$config = $this->get_config();
|
||||
$name = $config['host'] . ':' . $config['prefix'] . ':' . $config['databases'];
|
||||
@@ -112,10 +113,11 @@ SCRIPT;
|
||||
/**
|
||||
* 释放连接池
|
||||
* @throws ConfigException
|
||||
* @throws ComponentException
|
||||
*/
|
||||
public function release()
|
||||
{
|
||||
$connections = Snowflake::app()->pool->redis;
|
||||
$connections = Snowflake::app()->getPool()->getRedis();
|
||||
$connections->release($this->get_config(), true);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ class ErrorHandler extends Component implements ErrorInterface
|
||||
{
|
||||
$this->category = 'exception';
|
||||
|
||||
$event = Snowflake::app()->event;
|
||||
$event = Snowflake::app()->getEvent();
|
||||
$event->trigger(Event::RELEASE_ALL);
|
||||
|
||||
$this->sendError($exception->getMessage(), $exception->getFile(), $exception->getLine());
|
||||
@@ -102,7 +102,7 @@ class ErrorHandler extends Component implements ErrorInterface
|
||||
|
||||
logger()->error($data, 'error');
|
||||
|
||||
$event = Snowflake::app()->event;
|
||||
$event = Snowflake::app()->getEvent();
|
||||
$event->trigger(Event::RELEASE_ALL);
|
||||
|
||||
throw new \ErrorException($error[1], $error[0], 1, $error[2], $error[3]);
|
||||
|
||||
Reference in New Issue
Block a user