Skip to content

Commit

Permalink
Some updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Trehinos committed Mar 9, 2023
1 parent ccb7f88 commit 2fea12e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/res/config/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
app_vendor: Trehinos
app_name: Thor
app_version: 1.0.0
app_version_name: Thor v1
app_version_name: 'Thor v1'
env: DEV
lang: fr
timezone: Europe/Paris
Expand Down
3 changes: 2 additions & 1 deletion thor/Framework/Actions/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public function index(): Response
#[Route('index-page', '/index', HttpMethod::GET)]
public function indexPage(): Response
{
return $this->twigResponse('thor/pages/index.html.twig');
$this->addMessage("Ceci est un message de test", "Message TEST", "default", "Thor V1");
return $this->twigResponse('thor/pages/index.html.twig', retrieveMessages: true);
}

/**
Expand Down
1 change: 1 addition & 0 deletions thor/Framework/Factories/TwigFunctionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function (array|string $message) {
'warning' => ['exclamation-triangle', 'text-dark', '', 'text-dark bg-warning'],
'error', 'danger' => ['exclamation-triangle', 'text-danger', 'bg-danger text-light', ''],
'success', 'ok' => ['check', 'text-success', 'bg-success text-light', ''],
'default' => ['comment', 'text-dark', 'text-dark', 'bg-light text-dark'],
};
return <<<§
<div class="toast" role="alert">
Expand Down
11 changes: 8 additions & 3 deletions thor/Http/Client/CurlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
Request\HttpMethod,
Response\HttpStatus,
Request\RequestInterface,
Response\ResponseInterface};
Response\ResponseInterface
};

/**
* Provides an implementation of ClientInterface to send requests with Curl.
Expand Down Expand Up @@ -89,7 +90,11 @@ public function prepare(RequestInterface $request): self
},
]);
if ($this->preparedRequest->getMethod() !== HttpMethod::GET) {
curl_setopt($this->curl, CURLOPT_POSTFIELDS, $this->preparedRequest->getBody()->getContents());
curl_setopt(
$this->curl,
CURLOPT_POSTFIELDS,
json_decode($this->preparedRequest->getBody()->getContents(), true)
);
}

if (!in_array($request->getMethod(), [HttpMethod::GET, HttpMethod::POST])) {
Expand All @@ -111,7 +116,7 @@ public function prepare(RequestInterface $request): self
public static function toHeadersLines(array $headers): array
{
return array_map(
fn (string $key, array|string $value) => "$key: " . (is_string($value) ? $value : implode(', ', $value)),
fn(string $key, array|string $value) => "$key: " . (is_string($value) ? $value : implode(', ', $value)),
array_keys($headers),
array_values($headers),
);
Expand Down
3 changes: 3 additions & 0 deletions thor/Http/Request/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public static function normalizeFiles(array $files): array
private static function createUploadedFileFromSpec(array $value): UploadedFile|array
{
if (is_array($value['tmp_name'])) {
if ($value['tmp_name'][0] === '') {
return [];
}
return self::normalizeNestedFileSpec($value);
}
return new self(
Expand Down

0 comments on commit 2fea12e

Please sign in to comment.