Files
kiri-core/Annotation/Model/Relation.php
T
as2252258@163.com 682246df28 modify
2021-08-11 01:04:57 +08:00

45 lines
720 B
PHP

<?php
namespace Annotation\Model;
use Annotation\Attribute;
use Database\ActiveRecord;
use Exception;
use JetBrains\PhpStorm\Pure;
use Kiri\Kiri;
/**
* 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 mixed $class
* @param mixed|null $method
* @return bool
* @throws Exception
*/
public function execute(mixed $class, mixed $method = null): bool
{
$annotation = Kiri::getAnnotation();
$annotation->addRelate($class::class, $this->name, $method);
return true;
}
}