- Added a new TaskFetcher from annotation
This commit is contained in:
parent
6f8d554eeb
commit
59fa22ade0
|
@ -9,6 +9,8 @@ class Cronard implements \Notes\Annotation {
|
||||||
*/
|
*/
|
||||||
public string $cron;
|
public string $cron;
|
||||||
|
|
||||||
|
public string $method;
|
||||||
|
|
||||||
public function __construct($cron)
|
public function __construct($cron)
|
||||||
{
|
{
|
||||||
$this->cron = $cron;
|
$this->cron = $cron;
|
||||||
|
|
|
@ -26,8 +26,7 @@ class TaskFetcher {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->annotations = [
|
$this->annotations = [
|
||||||
#'object' => Annotation\Object\Cronard::class,
|
'method' => Annotation\Method\Cronard::class,
|
||||||
'method' => Annotation\Method\Route::class,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,26 +70,16 @@ class TaskFetcher {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$base = "";
|
|
||||||
$class = $this->generateClassname($file->getBasename(".php"), $namespace);
|
$class = $this->generateClassname($file->getBasename(".php"), $namespace);
|
||||||
$methods = $this->defaultMethods;
|
|
||||||
|
|
||||||
# Should generate an equivalent of Ulmus's object reflection here !
|
# Should generate an equivalent of Ulmus's object reflection here !
|
||||||
$objectResolver = new ObjectResolver($class, true, true, false, true);
|
$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'] );
|
$taskList = $objectResolver->getAnnotationListFromClassname( $this->annotations['method'] );
|
||||||
|
|
||||||
foreach($taskList as $func => $cronard) {
|
foreach($taskList as $func => $cronard) {
|
||||||
foreach($cronard as $task) {
|
foreach($cronard as $task) {
|
||||||
yield $task;
|
yield [ 'class' => $class, 'method' => $func, 'annotation' => $task ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue