From 59fa22ade019d54866ef643aa829ecc48ebf0930 Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Sun, 30 Jan 2022 00:14:25 +0000 Subject: [PATCH] - Added a new TaskFetcher from annotation --- src/Annotation/Method/Cronard.php | 2 ++ src/TaskFetcher.php | 15 ++------------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/Annotation/Method/Cronard.php b/src/Annotation/Method/Cronard.php index a3a533d..dc18efa 100644 --- a/src/Annotation/Method/Cronard.php +++ b/src/Annotation/Method/Cronard.php @@ -9,6 +9,8 @@ class Cronard implements \Notes\Annotation { */ public string $cron; + public string $method; + public function __construct($cron) { $this->cron = $cron; diff --git a/src/TaskFetcher.php b/src/TaskFetcher.php index 28dfd5b..2b67daa 100644 --- a/src/TaskFetcher.php +++ b/src/TaskFetcher.php @@ -26,8 +26,7 @@ class TaskFetcher { } else { $this->annotations = [ - #'object' => Annotation\Object\Cronard::class, - 'method' => Annotation\Method\Route::class, + 'method' => Annotation\Method\Cronard::class, ]; } } @@ -71,26 +70,16 @@ class TaskFetcher { continue; } - $base = ""; $class = $this->generateClassname($file->getBasename(".php"), $namespace); - $methods = $this->defaultMethods; # Should generate an equivalent of Ulmus's object reflection here ! $objectResolver = new ObjectResolver($class, true, true, false, true); - if ( null !== ( $object = $objectResolver->getAnnotationFromClassname( $this->annotations['object'] ) ) ) { - if ( $object->methods ?? false ) { - $methods = $object->methods; - } - - $base = $object->base ?? ""; - } - $taskList = $objectResolver->getAnnotationListFromClassname( $this->annotations['method'] ); foreach($taskList as $func => $cronard) { foreach($cronard as $task) { - yield $task; + yield [ 'class' => $class, 'method' => $func, 'annotation' => $task ]; } } }