This repository was archived by the owner on Dec 11, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 67
¡A practicar! Controller enriquecido #27
Open
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/.env.local | ||
/.env.*.local | ||
/.idea | ||
|
||
/apps/*/*/var/ | ||
|
||
|
4 changes: 4 additions & 0 deletions
apps/mooc/backend/config/routes/fino.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fino_get: | ||
path: /fino/{name} | ||
controller: CodelyTv\Apps\Mooc\Backend\Controller\Fino\FinoGetController | ||
methods: [GET] |
31 changes: 31 additions & 0 deletions
apps/mooc/backend/src/Controller/Fino/FinoGetController.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CodelyTv\Apps\Mooc\Backend\Controller\Fino; | ||
|
||
use CodelyTv\Shared\Domain\CurrentDateGenerator; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
final class FinoGetController | ||
{ | ||
private $date; | ||
|
||
public function __construct(CurrentDateGenerator $date) | ||
{ | ||
$this->date = $date->generate(); | ||
} | ||
|
||
public function __invoke(Request $request): Response | ||
{ | ||
$name = $request->get('name'); | ||
return new JsonResponse( | ||
[ | ||
'desc' => 'Todo va fino ' . $name, | ||
'date' => $this->date, | ||
] | ||
); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
src/Shared/Domain/CurrentDateGenerator.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace CodelyTv\Shared\Domain; | ||
|
||
interface CurrentDateGenerator | ||
{ | ||
public function generate(): string; | ||
} |
15 changes: 15 additions & 0 deletions
src/Shared/Infrastructure/PhpCurrentDateGenerator.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace CodelyTv\Shared\Infrastructure; | ||
|
||
use CodelyTv\Shared\Domain\CurrentDateGenerator; | ||
|
||
final class PhpCurrentDateGenerator implements CurrentDateGenerator | ||
{ | ||
public function generate(): string | ||
{ | ||
return date('Y-m-d H:i:s', strtotime('now')); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
tests/apps/mooc/backend/features/fino/fino_get.feature
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Feature: Fino endpoint | ||
In order to see todo va fino endpoind called by with name as param | ||
I want to check the Fino endpoint | ||
|
||
Scenario: Check the api status | ||
Given I send a GET request to "/fino/Carlitos" | ||
Then the response content should be: | ||
""" | ||
{ | ||
"desc": "Todo va fino Carlitos", | ||
"date": "2020年01月01日 00:00:00" | ||
} | ||
""" |
15 changes: 15 additions & 0 deletions
tests/src/Shared/Infrastructure/ConstantCurrentDateGenerator.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace CodelyTv\Tests\Shared\Infrastructure; | ||
|
||
use CodelyTv\Shared\Domain\CurrentDateGenerator; | ||
|
||
final class ConstantCurrentDateGenerator implements CurrentDateGenerator | ||
{ | ||
public function generate(): string | ||
{ | ||
return "2020年01月01日 00:00:00"; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.