- Some minor adjustements, also a WIP on the @Cronard annotation has begun

This commit is contained in:
Dave Mc Nicoll 2021-10-19 12:38:20 +00:00
parent fd693fc8fc
commit f72115aab4
3 changed files with 29 additions and 3 deletions

View File

@ -6,10 +6,13 @@ use Zend\Diactoros\Response\TextResponse;
use TheBugs\JavascriptMiddleware;
use Cronard\CronardMiddleware;
use Cronard\CronardMiddleware,
Notes\Cronard\TaskFetcher;
use Lean\Lean;
use Psr\Http\Message\ResponseInterface;
use Storage\Cookie,
Storage\Session,
Storage\SessionMiddleware;
@ -57,6 +60,8 @@ return [
],
'routes' => [],
'cronard' => [],
],
Lean::class => autowire(Lean::class),
@ -66,7 +71,17 @@ return [
return new TextResponse(sprintf("%s - cron task begin...", date('Y-m-d H:i:s')));
});
return $cronardMiddleware->fromFile(getenv("META_PATH")."/crontab.php");
return $cronardMiddleware->fromFile(getenv("META_PATH")."/crontab.php")->fromAnnotations($c->get(TaskFetcher::class));
},
TaskFetcher::class => function($c) {
$fetcher = new TaskFetcher();
$fetcher->setFolderList(array_map(function($item) {
return $item;
}, $c->get(Lean::class)->getCronard()));
return $fetcher;
},
JavascriptMiddleware::class => create(JavascriptMiddleware::class),

View File

@ -14,6 +14,8 @@ class Application
public array $routes;
public array $cronard;
public array $entities;
public array $tellJson;
@ -52,10 +54,14 @@ class Application
}
}
if (is_array($routes = $data['routes'] ?? false)) {
if (is_array($data['routes'] ?? false)) {
$this->routes = $data['routes'];
}
if (is_array($data['cronard'] ?? false)) {
$this->cronard = $data['cronard'];
}
return $this;
}
}

View File

@ -67,6 +67,11 @@ class Lean
return array_merge(...array_map(fn($app) => $app->routes ?? [], $this->applications));
}
public function getCronard() : array
{
return array_merge(...array_map(fn($app) => $app->cronard ?? [], $this->applications));
}
public function getEntities() : array
{
return array_merge(...array_map(fn($app) => $app->entities ?? [], $this->applications));