disply all offerings on homepage

This commit is contained in:
jannisp 2021-04-26 17:31:24 +02:00
parent 8ab7341dc6
commit 0cc7902f7f
6 changed files with 107 additions and 13 deletions

View file

@ -27,6 +27,7 @@
"symfony/yaml": "5.2.*", "symfony/yaml": "5.2.*",
"symfonycasts/verify-email-bundle": "^1.4", "symfonycasts/verify-email-bundle": "^1.4",
"twig/extra-bundle": "^2.12|^3.0", "twig/extra-bundle": "^2.12|^3.0",
"twig/intl-extra": "^3.3",
"twig/twig": "^2.12|^3.0" "twig/twig": "^2.12|^3.0"
}, },
"config": { "config": {

71
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "c6de01df386cc0add59c4fb1ed211ddf", "content-hash": "25e9fe3b823da6b1cae7cf742689d667",
"packages": [ "packages": [
{ {
"name": "composer/package-versions-deprecated", "name": "composer/package-versions-deprecated",
@ -7009,6 +7009,75 @@
], ],
"time": "2021-02-06T21:13:17+00:00" "time": "2021-02-06T21:13:17+00:00"
}, },
{
"name": "twig/intl-extra",
"version": "v3.3.0",
"source": {
"type": "git",
"url": "https://github.com/twigphp/intl-extra.git",
"reference": "919e8f945c30bd3efeb6a4d79722cda538116658"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/intl-extra/zipball/919e8f945c30bd3efeb6a4d79722cda538116658",
"reference": "919e8f945c30bd3efeb6a4d79722cda538116658",
"shasum": ""
},
"require": {
"php": ">=7.1.3",
"symfony/intl": "^4.3|^5.0",
"twig/twig": "^2.4|^3.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^4.4.9|^5.0.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.2-dev"
}
},
"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.3.0"
},
"funding": [
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
"type": "tidelift"
}
],
"time": "2021-01-01T14:58:18+00:00"
},
{ {
"name": "twig/twig", "name": "twig/twig",
"version": "v3.3.0", "version": "v3.3.0",

View file

@ -2,24 +2,27 @@
namespace App\Controller; namespace App\Controller;
use App\Repository\OfferingRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Twig\Environment;
class AppController extends AbstractController class AppController extends AbstractController
{ {
#[Route('/homepage', name: 'homepage')] #[Route('/', name: 'homepage')]
public function index(): Response public function index(Environment $twig, OfferingRepository $offeringRepository): Response
{ {
return $this->render('app/index.html.twig', [ return new Response($twig->render('app/index.html.twig', [
'controller_name' => 'AppController', 'offerings' => $offeringRepository->findAll(),
]); ]));
} }
#[Route('/user', name: 'user_page')] #[Route('/user', name: 'user_page')]
public function user(): Response public function user(): Response
{ {
return $this->render('app/index.html.twig', [ return $this->render('app/user.html.twig', [
'user' => $this->getUser(), 'user' => $this->getUser(),
]); ]);
} }

View file

@ -471,6 +471,9 @@
"twig/extra-bundle": { "twig/extra-bundle": {
"version": "v3.3.0" "version": "v3.3.0"
}, },
"twig/intl-extra": {
"version": "v3.3.0"
},
"twig/twig": { "twig/twig": {
"version": "v3.3.0" "version": "v3.3.0"
} }

View file

@ -1,9 +1,18 @@
{% extends 'base.html.twig' %} {% extends 'base.html.twig' %}
{% block title %}User{% endblock %}
{% block body %} {% block body %}
<div class="mb-3"> {% if offerings|length > 0 %}
<h1>Hello {{ user.username }}!</p> {% for offering in offerings %}
</div> {% if offering.photoFilename %}
<img src="{{ asset('uploads/photos/' ~ offering.photofilename) }}" />
{% endif %}
<h4>{{ offering.title }}</h4>
<small>
{{ offering.createdAt|format_datetime('medium', 'short') }}
</small>
{% endfor %}
{% else %}
<p>There are currently no active listings</p>
{% endif %}
{% endblock %} {% endblock %}

View file

@ -0,0 +1,9 @@
{% extends 'base.html.twig' %}
{% block title %}User{% endblock %}
{% block body %}
<div class="mb-3">
<h1>Hello {{ user.username }}!</p>
</div>
{% endblock %}