This commit is contained in:
2021-03-29 17:29:39 +08:00
parent c112fc839c
commit 9e54e20dae
6 changed files with 512 additions and 496 deletions
+1
View File
@@ -52,6 +52,7 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
* @param $query
* @param array $array
* @param null $model
* @throws Exception
*/
public function __construct($query, array $array = [], $model = null)
{
+2 -1
View File
@@ -157,7 +157,8 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
*/
public function createAnnotation()
{
$annotation = Snowflake::app()->getAttributes();
$annotation = Snowflake::getAnnotation();
$annotation->injectProperty($this);
$methods = $annotation->getMethods(get_called_class());
foreach ($methods as $method => $attributes) {
foreach ($attributes as $attribute) {
+12
View File
@@ -39,12 +39,24 @@ class Controller extends HttpService
/**
* Controller constructor.
* @param array $config
* @throws Exception
*/
public function __construct($config = [])
{
parent::__construct($config);
}
/**
* @throws Exception
*/
public function init()
{
$annotation = Snowflake::getAnnotation();
$annotation->injectProperty($this);
}
/**
* @param null|HttpParams $input
*/
-9
View File
@@ -45,15 +45,6 @@ class BaseObject implements Configure
*/
public function init()
{
$app = Snowflake::app();
if (!($app instanceof Application)) {
return;
}
if (!$app->has('attributes')) {
return;
}
$attributes = $app->getAttributes();
$attributes->injectProperty($this);
}
+12 -1
View File
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Snowflake;
use Annotation\Annotation;
use Exception;
use HttpServer\IInterface\Task;
@@ -85,7 +86,7 @@ class Snowflake
/**
* @param $port
* @return bool|array
* @return bool
* @throws Exception
*/
public static function port_already($port): bool
@@ -102,6 +103,16 @@ class Snowflake
}
/**
* @return Annotation
* @throws Exception
*/
public static function getAnnotation(): Annotation
{
return static::app()->getAttributes();
}
/**
* @param $service
* @return string
+2 -2
View File
@@ -65,7 +65,7 @@ if (!function_exists('annotation')) {
*/
function annotation(): Annotation
{
return Snowflake::app()->getAttributes();
return Snowflake::getAnnotation();
}
@@ -81,7 +81,7 @@ if (!function_exists('recursive_directory')) {
*/
function recursive_callback(DirectoryIterator $file)
{
$attributes = Snowflake::app()->getAttributes();
$attributes = Snowflake::getAnnotation();
$annotations = $attributes->getFilename($file->getRealPath());
if (empty($annotations)) {