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

44 lines
629 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;
/**
* 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-03-04 15:05:46 +08:00
public function execute(array $handler): bool
2021-03-04 14:24:45 +08:00
{
2021-03-04 15:05:46 +08:00
/** @var ActiveRecord $activeRecord */
[$activeRecord, $method] = $handler;
2021-03-04 14:24:45 +08:00
2021-03-04 15:05:46 +08:00
$activeRecord->setRelate($this->name, $method);
return true;
2021-03-04 14:24:45 +08:00
}
}