52 lines
1.6 KiB
PHP
52 lines
1.6 KiB
PHP
|
<?php
|
||
|
|
||
|
use function DI\autowire, DI\create, DI\get;
|
||
|
|
||
|
use Psr\Http\Message\ResponseInterface;
|
||
|
|
||
|
use Mcnd\CLI\CliMiddleware;
|
||
|
|
||
|
use Notes\CLI\CommandFetcher;
|
||
|
|
||
|
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;
|
||
|
},*/
|
||
|
|
||
|
CommandFetcher::class => function($c) {
|
||
|
$fetcher = new CommandFetcher(null, null, $c->get('cli.caching'));
|
||
|
|
||
|
$fetcher->setFolderList(array_map(function($item) {
|
||
|
return $item;
|
||
|
}, $c->get(Lean::class)->getCli()));
|
||
|
|
||
|
return $fetcher;
|
||
|
},
|
||
|
|
||
|
CliMiddleware::class => function($c) {
|
||
|
return new CliMiddleware($c, $c->get('cli.response:default'), $c->get(CommandFetcher::class));
|
||
|
},
|
||
|
|
||
|
'cli.response:default' => function($c) {
|
||
|
return function() {
|
||
|
return new \Laminas\Diactoros\Response\TextResponse("This is the default response from CLI middleware which indicates that no command were registered for this application.\n");
|
||
|
};
|
||
|
},
|
||
|
];
|