改名
This commit is contained in:
@@ -24,6 +24,7 @@ use Database\Relation;
|
|||||||
use Database\SqlBuilder;
|
use Database\SqlBuilder;
|
||||||
use Database\Traits\HasBase;
|
use Database\Traits\HasBase;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use JetBrains\PhpStorm\Pure;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use Snowflake\Abstracts\Component;
|
use Snowflake\Abstracts\Component;
|
||||||
use Snowflake\Abstracts\Config;
|
use Snowflake\Abstracts\Config;
|
||||||
@@ -42,6 +43,7 @@ use validator\Validator;
|
|||||||
* @property bool $isCreate
|
* @property bool $isCreate
|
||||||
* @method rules()
|
* @method rules()
|
||||||
* @method static tableName()
|
* @method static tableName()
|
||||||
|
* @property Application $application
|
||||||
*/
|
*/
|
||||||
abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
||||||
{
|
{
|
||||||
@@ -70,19 +72,12 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
|||||||
/** @var null|string */
|
/** @var null|string */
|
||||||
protected ?string $primary = NULL;
|
protected ?string $primary = NULL;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private array $_annotations = [];
|
private array $_annotations = [];
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Application|null
|
|
||||||
*/
|
|
||||||
protected ?Application $container;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
@@ -107,6 +102,15 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
|||||||
*/
|
*/
|
||||||
private array $_with = [];
|
private array $_with = [];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Application
|
||||||
|
*/
|
||||||
|
#[Pure] public function getApplication(): Application
|
||||||
|
{
|
||||||
|
return Snowflake::app();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $data
|
* @param $data
|
||||||
* @return ActiveRecord
|
* @return ActiveRecord
|
||||||
@@ -154,7 +158,6 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
|||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->container = Snowflake::app();
|
|
||||||
$an = Snowflake::app()->getAnnotation();
|
$an = Snowflake::app()->getAnnotation();
|
||||||
$an->injectProperty($this);
|
$an->injectProperty($this);
|
||||||
}
|
}
|
||||||
@@ -773,7 +776,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param string|null $name
|
||||||
* @param string $method
|
* @param string $method
|
||||||
* @return string|null
|
* @return string|null
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
@@ -856,7 +859,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
|||||||
* @param string $type
|
* @param string $type
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getAnnotation($type = self::GET): array
|
protected function getAnnotation(string $type = self::GET): array
|
||||||
{
|
{
|
||||||
return $this->_annotations[$type] ?? [];
|
return $this->_annotations[$type] ?? [];
|
||||||
}
|
}
|
||||||
@@ -867,7 +870,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
|||||||
* @param string $type
|
* @param string $type
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function hasAnnotation($name, $type = self::GET): bool
|
protected function hasAnnotation($name, string $type = self::GET): bool
|
||||||
{
|
{
|
||||||
if (!isset($this->_annotations[$type])) {
|
if (!isset($this->_annotations[$type])) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class Snowflake
|
|||||||
* @param $name
|
* @param $name
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function has($name): bool
|
#[Pure] public static function has($name): bool
|
||||||
{
|
{
|
||||||
return static::$service->has($name);
|
return static::$service->has($name);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user