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

45 lines
622 B
PHP
Raw Normal View History

2021-01-19 17:45:33 +08:00
<?php
namespace Annotation\Model;
2021-02-22 17:44:24 +08:00
use Annotation\Annotation;
2021-01-19 17:45:33 +08:00
use Attribute;
2021-01-20 15:45:53 +08:00
use Database\ActiveRecord;
2021-01-19 17:45:33 +08:00
/**
* Class Get
* @package Annotation\Model
*/
2021-03-03 18:35:04 +08:00
#[Attribute(Attribute::TARGET_METHOD)] class Get extends \Annotation\Attribute
2021-01-19 17:45:33 +08:00
{
2021-01-20 15:46:26 +08:00
/**
* Get constructor.
* @param string $name
*/
2021-01-19 17:48:28 +08:00
public function __construct(
public string $name
)
2021-01-19 17:45:33 +08:00
{
}
2021-02-22 17:44:24 +08:00
/**
* @param array $handler
2021-03-03 18:35:04 +08:00
* @return ActiveRecord
2021-02-22 17:44:24 +08:00
*/
2021-03-03 18:35:04 +08:00
public function execute(array $handler): ActiveRecord
2021-02-22 17:44:24 +08:00
{
2021-03-03 18:35:04 +08:00
/** @var ActiveRecord $activeRecord */
[$activeRecord, $method] = $handler;
2021-02-22 17:44:24 +08:00
2021-03-03 18:35:04 +08:00
return $activeRecord->addGets($this->name, $method);
2021-02-22 17:44:24 +08:00
}
2021-01-19 17:45:33 +08:00
}