modify
This commit is contained in:
+18
-20
@@ -7,6 +7,7 @@ namespace Annotation\Model;
|
||||
use Annotation\Annotation;
|
||||
use Attribute;
|
||||
use Database\ActiveRecord;
|
||||
use Snowflake\Snowflake;
|
||||
|
||||
|
||||
/**
|
||||
@@ -17,28 +18,25 @@ use Database\ActiveRecord;
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Get constructor.
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct(
|
||||
public string $name
|
||||
)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Get constructor.
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct(public string $name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $handler
|
||||
* @return ActiveRecord
|
||||
*/
|
||||
public function execute(array $handler): ActiveRecord
|
||||
{
|
||||
/** @var ActiveRecord $activeRecord */
|
||||
[$activeRecord, $method] = $handler;
|
||||
|
||||
return $activeRecord->addGets($this->name, $method);
|
||||
}
|
||||
/**
|
||||
* @param array $handler
|
||||
* @return ActiveRecord
|
||||
*/
|
||||
public function execute(mixed $class, mixed $method = null): bool
|
||||
{
|
||||
$annotation = Snowflake::getAnnotation();
|
||||
$annotation->addGets($class::class, $this->name, $method);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Annotation\Model;
|
||||
use Annotation\Attribute;
|
||||
use Database\ActiveRecord;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Snowflake\Snowflake;
|
||||
|
||||
|
||||
/**
|
||||
@@ -30,14 +31,11 @@ use JetBrains\PhpStorm\Pure;
|
||||
* @param array $handler
|
||||
* @return bool
|
||||
*/
|
||||
public function execute(array $handler): bool
|
||||
public function execute(mixed $class, mixed $method = null): bool
|
||||
{
|
||||
/** @var ActiveRecord $activeRecord */
|
||||
[$activeRecord, $method] = $handler;
|
||||
|
||||
$activeRecord->setRelate($this->name, $method);
|
||||
|
||||
return true;
|
||||
$annotation = Snowflake::getAnnotation();
|
||||
$annotation->addRelate($class::class, $this->name, $method);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+11
-10
@@ -6,6 +6,7 @@ namespace Annotation\Model;
|
||||
|
||||
use Annotation\Attribute;
|
||||
use Database\ActiveRecord;
|
||||
use Snowflake\Snowflake;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Set extends Attribute
|
||||
{
|
||||
@@ -20,17 +21,17 @@ use Database\ActiveRecord;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param array $handler
|
||||
* @return ActiveRecord
|
||||
*/
|
||||
public function execute(array $handler): ActiveRecord
|
||||
/**
|
||||
* @param mixed $class
|
||||
* @param mixed|null $method
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function execute(mixed $class, mixed $method = null): bool
|
||||
{
|
||||
/** @var ActiveRecord $activeRecord */
|
||||
[$activeRecord, $method] = $handler;
|
||||
|
||||
return $activeRecord->addSets($this->name, $method);
|
||||
$annotation = Snowflake::getAnnotation();
|
||||
$annotation->addSets($class::class, $this->name, $method);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user