mirror of
https://gitee.com/ctexthuang/hyperf-micro-svc.git
synced 2026-02-08 10:20:16 +08:00
first commit
This commit is contained in:
20
app/Repository/Traits/BootTrait.php
Normal file
20
app/Repository/Traits/BootTrait.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository\Traits;
|
||||
|
||||
use function Hyperf\Support\class_basename;
|
||||
use function Hyperf\Support\class_uses_recursive;
|
||||
|
||||
trait BootTrait
|
||||
{
|
||||
protected function startBoot(...$params): void
|
||||
{
|
||||
$traits = class_uses_recursive(static::class);
|
||||
foreach ($traits as $trait) {
|
||||
$method = 'boot' . class_basename($trait);
|
||||
if (method_exists($this, $method)) {
|
||||
$this->{$method}(...$params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user