- Added PPH-DI definition file

This commit is contained in:
Dave M. 2023-11-15 22:13:22 -05:00
parent 19aa25df1b
commit d503628356
2 changed files with 43 additions and 1 deletions

View File

@ -14,5 +14,14 @@
"psr-4": { "psr-4": {
"Mcnd\\CLI\\": "src/" "Mcnd\\CLI\\": "src/"
} }
},
"extra": {
"lean": {
"autoload": {
"definitions": [
"meta/definitions.php"
]
}
}
} }
} }

33
meta/definitions.php Normal file
View File

@ -0,0 +1,33 @@
<?php
use function DI\autowire, DI\create, DI\get;
use Psr\Http\Message\ResponseInterface;
use Mcnd\CLI\CliMiddleware;
use Notes\CLI\CommandFetcher;
use Lean\{ Factory, Lean };
return [
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 Factory\HttpFactory::createTextResponse("This is the default response from CLI middleware which indicates that no command were registered for this application.\n");
};
},
];