This commit is contained in:
2020-09-02 19:34:45 +08:00
parent 4e881c628b
commit de30c44709
4 changed files with 92 additions and 1 deletions
-1
View File
@@ -123,7 +123,6 @@ class Server extends Application
$application = Snowflake::get();
foreach ($processes as $name => $process) {
$class = Snowflake::createObject($process);
if (!method_exists($class, 'onHandler')) {
continue;
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace Snowflake\Abstracts;
use Snowflake\Core\Dtl;
interface IListener
{
public function handler(Dtl $dtl);
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace Snowflake\Abstracts;
/**
* Class Listener
* @package Snowflake\Abstracts
* 监听的名称
*/
abstract class Listener extends Component implements IListener
{
protected $name = '';
}
+59
View File
@@ -0,0 +1,59 @@
<?php
namespace Snowflake\Core;
use Exception;
use Snowflake\Abstracts\Component;
/**
* Class Dtl
* @package Snowflake\Core
*/
class Dtl extends Component
{
protected $params;
/**
* Dtl constructor.
* @param $params
*/
public function __construct($params)
{
parent::__construct([]);
$this->params = $params;
}
/**
* @return mixed
* @throws Exception
*/
public function toArray()
{
if (!is_array($this->params)) {
return ArrayAccess::toArray($this->params);
}
return $this->params;
}
/**
* @param $name
* @return mixed|null
* @throws Exception
*/
public function get($name)
{
$array = $this->toArray();
if (!isset($array[$name])) {
return null;
}
return $array[$name];
}
}