- A lot of fixes done on this for a test project.
This commit is contained in:
1 parent
52e55f2bba
commit
09b3e47c19
11 files changed
+78
-21
No files matched your search
+13
-1
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Lean;
|
||||
|
||||
use CSLSJ\Common\RequestResponse\DownloadResponse;
|
||||
use CSLSJ\Common\RequestResponse\ImageResponse;
|
||||
use Picea,
|
||||
Picea\Ui\Method\FormContext;
|
||||
|
||||
@@ -35,7 +37,7 @@ trait ControllerTrait {
|
||||
public ? MailerInterface $mailer;
|
||||
|
||||
public array $contextList = [];
|
||||
#medias
|
||||
|
||||
public function exportJson(ServerRequestInterface $request, string $entityClass, bool $includeRelations = true, ? callable $callback = null) : ResponseInterface
|
||||
{
|
||||
foreach($entityClass::repository()->filterServerRequest( $entityClass::searchRequest()->fromRequest($request->withQueryParams($request->getQueryParams() + ['limit' => PHP_INT_MAX,])) )->loadAll() as $entity) {
|
||||
@@ -76,6 +78,16 @@ trait ControllerTrait {
|
||||
return new JsonResponse($data, $code, $headers);
|
||||
}
|
||||
|
||||
public static function renderDownloadable(string $data, string $filename, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new DownloadResponse($data, $filename, $code, $headers);
|
||||
}
|
||||
|
||||
public static function renderImage(string $data, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new ImageResponse($data, $code, $headers);
|
||||
}
|
||||
|
||||
public function fromResponse(ResponseInterface $response)
|
||||
{
|
||||
if ( $response->getStatusCode() === 200 ) {
|
||||
|
||||
Reference in new issue
Block a user