Files
kiri-core/Annotation/Model/Relation.php
T
2021-03-04 15:05:46 +08:00

44 lines
629 B
PHP

<?php
namespace Annotation\Model;
use Annotation\Attribute;
use Database\ActiveRecord;
use JetBrains\PhpStorm\Pure;
/**
* 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
* @return bool
*/
public function execute(array $handler): bool
{
/** @var ActiveRecord $activeRecord */
[$activeRecord, $method] = $handler;
$activeRecord->setRelate($this->name, $method);
return true;
}
}