From 85a4dd33ce746ff10d7bbee6833620158b1e6824 Mon Sep 17 00:00:00 2001 From: slowlyo Date: Fri, 19 Jul 2024 00:05:11 +0800 Subject: [PATCH] feat: pipeline --- src/Support/Cores/AdminPipeline.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Support/Cores/AdminPipeline.php b/src/Support/Cores/AdminPipeline.php index 54e64196..aa08cb65 100644 --- a/src/Support/Cores/AdminPipeline.php +++ b/src/Support/Cores/AdminPipeline.php @@ -56,6 +56,17 @@ public static function handle($key, $passable, callable $callback = null) return admin_pipeline($passable)->through($pipes)->then(fn($i) => $do($i)); } + /** + * @param $key + * @param callable $callback + * + * @return mixed + */ + public static function tap($key, callable $callback) + { + return self::handle($key, null, $callback); + } + /** * @param array|mixed $pipes * @@ -65,4 +76,13 @@ public static function through($key, $pipes) { Admin::context()->set($key, $pipes); } + + public static function parseKey($suffix = '', $getChild = false) + { + $callUser = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2)[1]; + + $callUser = $getChild ? get_class($callUser['object']) : $callUser['class']; + + return $callUser . ($suffix ? ':' . $suffix : ''); + } }