Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

¡A practicar! Controller enriquecido #27

Open
atorobodas wants to merge 1 commit into CodelyTV:main
base: main
Choose a base branch
Loading
from atorobodas:vafino
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.env.local
/.env.*.local
/.idea

/apps/*/*/var/

Expand Down
4 changes: 4 additions & 0 deletions apps/mooc/backend/config/routes/fino.yaml
View file Open in desktop
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
View file Open in desktop
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
View file Open in desktop
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
View file Open in desktop
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
View file Open in desktop
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
View file Open in desktop
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";
}
}

AltStyle によって変換されたページ (->オリジナル) /