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

45 lines
713 B
PHP
Raw Normal View History

2021-03-04 14:24:45 +08:00
<?php
namespace Annotation\Model;
use Annotation\Attribute;
use Database\ActiveRecord;
2021-07-12 17:17:36 +08:00
use Exception;
2021-03-04 14:24:45 +08:00
use JetBrains\PhpStorm\Pure;
2021-08-11 01:04:57 +08:00
use Kiri\Kiri;
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)
{
}
/**
2021-07-12 17:17:36 +08:00
* @param mixed $class
* @param mixed|null $method
2021-03-04 15:05:46 +08:00
* @return bool
2021-07-12 17:17:36 +08:00
* @throws Exception
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-08-11 01:04:57 +08:00
$annotation = Kiri::getAnnotation();
2021-08-13 15:19:07 +08:00
$annotation->addRelate($class, $this->name, $method);
2021-05-03 03:48:52 +08:00
return true;
2021-03-04 14:24:45 +08:00
}
}