- 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

+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 ) {