33 lines
		
	
	
		
			947 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			947 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| use function DI\autowire, DI\create, DI\get;
 | |
| 
 | |
| use Laminas\Diactoros\Response\HtmlResponse;
 | |
| 
 | |
| use Cronard\CronardMiddleware,
 | |
|     Notes\Cronard\TaskFetcher;
 | |
| 
 | |
| use Psr\Http\Message\ResponseInterface;
 | |
| 
 | |
| use Lean\Lean;
 | |
| 
 | |
| return [
 | |
|     CronardMiddleware::class => function($c) {
 | |
|         $cronardMiddleware = new CronardMiddleware($c, getenv('CRON_KEY'), function() : ResponseInterface {
 | |
|             return new HtmlResponse(sprintf("%s - cron task begin...", date('Y-m-d H:i:s')));
 | |
|         }, [], $c->get(TaskFetcher::class));
 | |
| 
 | |
|         return $cronardMiddleware->fromFile(getenv("META_PATH")."/crontab.php")->fromAnnotations($c->get(TaskFetcher::class));
 | |
|     },
 | |
| 
 | |
|     TaskFetcher::class => function($c) {
 | |
|         $fetcher = new TaskFetcher(null, null, $c->get('cronard.caching'));
 | |
| 
 | |
|         $fetcher->setFolderList(array_map(function($item) {
 | |
|             return $item;
 | |
|         }, $c->get(Lean::class)->getCronard()));
 | |
| 
 | |
|         return $fetcher;
 | |
|     },
 | |
| ];
 |