改名
This commit is contained in:
@@ -7,7 +7,7 @@ namespace Snowflake\Abstracts;
|
||||
|
||||
/**
|
||||
* Class BaseAnnotation
|
||||
* @package BeReborn\Annotation\Base
|
||||
* @package Snowflake\Snowflake\Annotation\Base
|
||||
*/
|
||||
abstract class BaseAnnotation extends Component
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ use Snowflake\Event;
|
||||
|
||||
/**
|
||||
* Class BaseApplication
|
||||
* @package BeReborn\Base
|
||||
* @package Snowflake\Snowflake\Base
|
||||
* @property $json
|
||||
* @property Annotation $annotation
|
||||
* @property Event $event
|
||||
@@ -38,6 +38,7 @@ use Snowflake\Event;
|
||||
* @property \Snowflake\Pool\Pool $pool
|
||||
* @property Server $servers
|
||||
* @property Connection $connections
|
||||
* @property Logger $logger
|
||||
*/
|
||||
abstract class BaseApplication extends Service
|
||||
{
|
||||
@@ -192,6 +193,17 @@ abstract class BaseApplication extends Service
|
||||
return current($this->getLocalIps());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Logger
|
||||
* @throws ComponentException
|
||||
*/
|
||||
public function getLogger(): Logger
|
||||
{
|
||||
return $this->get('logger');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $ip
|
||||
* @return bool
|
||||
|
||||
@@ -15,7 +15,7 @@ use Snowflake\Snowflake;
|
||||
/**
|
||||
* Class BaseObject
|
||||
* @method defer()
|
||||
* @package BeReborn\Base
|
||||
* @package Snowflake\Snowflake\Base
|
||||
* @method afterInit
|
||||
* @method initialization
|
||||
*/
|
||||
|
||||
@@ -10,10 +10,11 @@ namespace Snowflake\Abstracts;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Snowflake\Snowflake;
|
||||
|
||||
/**
|
||||
* Class Component
|
||||
* @package BeReborn\Base
|
||||
* @package Snowflake\Snowflake\Base
|
||||
*/
|
||||
class Component extends BaseObject
|
||||
{
|
||||
@@ -73,6 +74,7 @@ class Component extends BaseObject
|
||||
*/
|
||||
public function trigger($name, $event = null, $params = [], $isRemove = false)
|
||||
{
|
||||
$aEvents = Snowflake::get()->event;
|
||||
if (isset($this->_events[$name])) {
|
||||
$events = $this->_events[$name];
|
||||
foreach ($events as $key => $_event) {
|
||||
@@ -82,11 +84,11 @@ class Component extends BaseObject
|
||||
call_user_func($_event, ...$params);
|
||||
if ($isRemove) {
|
||||
unset($this->_events[$name][$key]);
|
||||
of($name, $_event);
|
||||
$aEvents->of($name, $_event);
|
||||
}
|
||||
}
|
||||
}
|
||||
fire($name, $event);
|
||||
$aEvents->trigger($name, $event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,14 +98,15 @@ class Component extends BaseObject
|
||||
*/
|
||||
public function off($name, $handler = NULL)
|
||||
{
|
||||
$aEvents = Snowflake::get()->event;
|
||||
if (!isset($this->_events[$name])) {
|
||||
return of($name, $handler);
|
||||
return $aEvents->of($name, $handler);
|
||||
}
|
||||
|
||||
if (empty($handler)) {
|
||||
unset($this->_events[$name]);
|
||||
|
||||
return of($name, $handler);
|
||||
return $aEvents->of($name, $handler);
|
||||
}
|
||||
|
||||
foreach ($this->_events[$name] as $key => $val) {
|
||||
@@ -114,7 +117,7 @@ class Component extends BaseObject
|
||||
|
||||
break;
|
||||
}
|
||||
return of($name, $handler);
|
||||
return $aEvents->of($name, $handler);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +125,8 @@ class Component extends BaseObject
|
||||
public function offAll()
|
||||
{
|
||||
$this->_events = [];
|
||||
ofAll();
|
||||
$aEvents = Snowflake::get()->event;
|
||||
$aEvents->clean();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ use Snowflake\Abstracts\Component;
|
||||
|
||||
/**
|
||||
* Class Config
|
||||
* @package BeReborn\Base
|
||||
* @package Snowflake\Snowflake\Base
|
||||
*/
|
||||
class Config extends Component
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Snowflake\Abstracts;
|
||||
|
||||
/**
|
||||
* Interface Configure
|
||||
* @package BeReborn\Base
|
||||
* @package Snowflake\Snowflake\Base
|
||||
*/
|
||||
interface Configure
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ use Swoole\Coroutine\Channel;
|
||||
|
||||
/**
|
||||
* Class Pool
|
||||
* @package BeReborn\Pool
|
||||
* @package Snowflake\Snowflake\Pool
|
||||
*/
|
||||
abstract class Pool extends Component
|
||||
{
|
||||
@@ -41,6 +41,7 @@ abstract class Pool extends Component
|
||||
* @param $name
|
||||
* @param int $timeout
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function get($name, $timeout = -1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user