- Working on CLI modules
This commit is contained in:
1 parent
52c7407519
commit
41083c767a
10 files changed
+90
-4
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -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"),
|
||||
|
||||
Reference in new issue
Block a user