Files
kiri-core/Annotation/Model/Relation.php
T

42 lines
670 B
PHP
Raw Normal View History

2021-03-04 14:24:45 +08:00
<?php
namespace Annotation\Model;
use Annotation\Attribute;
use Database\ActiveRecord;
use JetBrains\PhpStorm\Pure;
2021-05-03 03:48:52 +08:00
use Snowflake\Snowflake;
2021-03-04 14:24:45 +08:00
/**
* Class Relation
* @package Annotation\Model
*/
#[\Attribute(\Attribute::TARGET_METHOD)] class Relation extends Attribute
{
/**
* Relation constructor.
* @param string $name
*/
public function __construct(public string $name)
{
}
/**
* @param array $handler
2021-03-04 15:05:46 +08:00
* @return bool
2021-03-04 14:24:45 +08:00
*/
2021-05-03 03:48:52 +08:00
public function execute(mixed $class, mixed $method = null): bool
2021-03-04 14:24:45 +08:00
{
2021-05-03 03:48:52 +08:00
$annotation = Snowflake::getAnnotation();
$annotation->addRelate($class::class, $this->name, $method);
return true;
2021-03-04 14:24:45 +08:00
}
}