- 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 $method;
 | 
			
		||||
 | 
			
		||||
    public function __construct($cron)
 | 
			
		||||
    {
 | 
			
		||||
        $this->cron = $cron;
 | 
			
		||||
 | 
			
		||||
@ -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 ];
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user