- Working on CLI modules

This commit is contained in:
mcndave committed 2023-07-09 12:37:39 -04:00
1 parent 52c7407519
commit 41083c767a
10 files changed
+90 -4

No files matched your search

+7
View File
@@ -16,6 +16,8 @@ class Application
public array $routes;
public array $cli;
public array $cronard;
public array $entities;
@@ -73,10 +75,15 @@ class Application
if (is_array($data['cronard'] ?? false)) {
$this->cronard = $data['cronard'];
}
if (is_array($data['events'] ?? false)) {
$this->events = $data['events'];
}
if (is_array($data['cli'] ?? false)) {
$this->cli = $data['cli'];
}
return $this;
}
}
+16
View File
@@ -117,6 +117,22 @@ trait ControllerTrait {
return new FileDownloadResponse($path, $code, $headers);
}
public function renderCLI(ServerRequestInterface $request, mixed $data) : ResponseInterface
{
if ($data instanceof \JsonSerializable ) {
return $this->renderJson(
$data
);
}
elseif ( is_array($data) ) {
var_export($data);
}
return $this->renderText(
$data . PHP_EOL
);
}
public function fromResponse(ResponseInterface $response)
{
if ( $response->getStatusCode() === 200 ) {
+6
View File
@@ -83,6 +83,11 @@ class Lean
return array_merge(...array_map(fn($app) => $app->cronard ?? [], $this->applications));
}
public function getCLI() : array
{
return array_merge(...array_map(fn($app) => $app->cli ?? [], $this->applications));
}
public function getEvents() : array
{
return array_merge(...array_map(fn($app) => $app->events ?? [], $this->applications));
@@ -128,6 +133,7 @@ class Lean
$path = dirname(__DIR__) . "/meta/definitions/";
return array_merge(
require($path . "cli.php"),
require($path . "cronard.php"),
require($path . "email.php"),
require($path . "event.php"),