Build user interface prototype
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
"symfony/yaml": "6.4.*",
|
||||
"symfonycorp/platformsh-meta": "^1.0",
|
||||
"twig/extra-bundle": "^2.12|^3.0",
|
||||
"twig/intl-extra": "^3",
|
||||
"twig/twig": "^2.12|^3.0"
|
||||
},
|
||||
"config": {
|
||||
|
||||
66
composer.lock
generated
66
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "4a519caa6276f3bc3a66cec485313e3b",
|
||||
"content-hash": "8c1a998d0fd531901efdf4231f51010e",
|
||||
"packages": [
|
||||
{
|
||||
"name": "blackfire/php-sdk",
|
||||
@@ -7812,6 +7812,70 @@
|
||||
],
|
||||
"time": "2024-05-11T07:35:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "twig/intl-extra",
|
||||
"version": "v3.10.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/twigphp/intl-extra.git",
|
||||
"reference": "693f6beb8ca91fc6323e01b3addf983812f65c93"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/twigphp/intl-extra/zipball/693f6beb8ca91fc6323e01b3addf983812f65c93",
|
||||
"reference": "693f6beb8ca91fc6323e01b3addf983812f65c93",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"symfony/intl": "^5.4|^6.4|^7.0",
|
||||
"twig/twig": "^3.10"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "^6.4|^7.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Twig\\Extra\\Intl\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com",
|
||||
"homepage": "http://fabien.potencier.org",
|
||||
"role": "Lead Developer"
|
||||
}
|
||||
],
|
||||
"description": "A Twig extension for Intl",
|
||||
"homepage": "https://twig.symfony.com",
|
||||
"keywords": [
|
||||
"intl",
|
||||
"twig"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/twigphp/intl-extra/tree/v3.10.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-05-11T07:35:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v3.10.3",
|
||||
|
||||
@@ -2,22 +2,30 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Conference;
|
||||
use App\Repository\CommentRepository;
|
||||
use App\Repository\ConferenceRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Twig\Environment;
|
||||
|
||||
class ConferenceController extends AbstractController
|
||||
{
|
||||
#[Route('/', name: 'homepage')]
|
||||
public function index(): Response
|
||||
public function index(Environment $twig, ConferenceRepository $conferenceRepository): Response
|
||||
{
|
||||
return new Response(<<<EOF
|
||||
<html>
|
||||
<body>
|
||||
<img src="/images/under-construction.gif" />
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
);
|
||||
return new Response($twig->render('conference/index.html.twig', [
|
||||
'conferences' => $conferenceRepository->findAll(),
|
||||
]));
|
||||
}
|
||||
|
||||
#[Route('/conference/{id}', name: 'conference')]
|
||||
public function show(Environment $twig, Conference $conference, CommentRepository $commentRepository): Response
|
||||
{
|
||||
return new Response($twig->render('conference/show.html.twig', [
|
||||
'conference' => $conference,
|
||||
'comments' => $commentRepository->findBy(['conference' => $conference], ['createdAt' => 'DESC']),
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Hello ConferenceController!{% endblock %}
|
||||
{% block title %}Conference Guestbook{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<style>
|
||||
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
|
||||
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
|
||||
</style>
|
||||
<h2>Give your feedback!</h2>
|
||||
|
||||
<div class="example-wrapper">
|
||||
<h1>Hello {{ controller_name }}! ✅</h1>
|
||||
|
||||
This friendly message is coming from:
|
||||
<ul>
|
||||
<li>Your controller at <code>/home/pablo_rodriguez/guestbook/src/Controller/ConferenceController.php</code></li>
|
||||
<li>Your template at <code>/home/pablo_rodriguez/guestbook/templates/conference/index.html.twig</code></li>
|
||||
</ul>
|
||||
</div>
|
||||
{% for conference in conferences %}
|
||||
<h4>{{ conference }}</h4>
|
||||
<p>
|
||||
<a href="{{ path('conference', { id: conference.id }) }}">View</a>
|
||||
</p>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
24
templates/conference/show.html.twig
Normal file
24
templates/conference/show.html.twig
Normal file
@@ -0,0 +1,24 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Conference Guestbook - {{ conference }}{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h2>{{ conference }} Conference<h2>
|
||||
|
||||
{% if comments|length > 0 %}
|
||||
{% for comment in comments %}
|
||||
{% if comment.photoFilename %}
|
||||
<img src="{{ asset('uploads/photos/' ~ comment.photofilename) }}" style="max-width: 200px"/>
|
||||
{% endif %}
|
||||
|
||||
<h4>{{ comment.author }}</h4>
|
||||
<small>
|
||||
{{ comment.createdAt|format_datetime('medium', 'short') }}
|
||||
</small>
|
||||
|
||||
<p>{{ comment.text }}</p>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div>No comments have been posted yet for this conference.</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user