- Added a new TaskFetcher from annotation

This commit is contained in:
Dave Mc Nicoll 2022-01-30 00:14:25 +00:00
parent 6f8d554eeb
commit 59fa22ade0
2 changed files with 4 additions and 13 deletions

View File

@ -9,6 +9,8 @@ class Cronard implements \Notes\Annotation {
*/
public string $cron;
public string $method;
public function __construct($cron)
{
$this->cron = $cron;

View File

@ -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 ];
}
}
}