From 23c3a2467200c5cb6941925fe48af15af8383610 Mon Sep 17 00:00:00 2001 From: thisfro Date: Sat, 1 May 2021 15:33:45 +0200 Subject: [PATCH] show details of offer --- composer.json | 1 + composer.lock | 80 ++++++++++++++++++++- config/bundles.php | 1 + config/packages/sensio_framework_extra.yaml | 3 + src/Controller/AppController.php | 4 +- src/Entity/Offering.php | 5 ++ symfony.lock | 12 ++++ templates/app/index.html.twig | 2 +- templates/app/offer.html.twig | 21 ++++++ 9 files changed, 125 insertions(+), 4 deletions(-) create mode 100644 config/packages/sensio_framework_extra.yaml create mode 100644 templates/app/offer.html.twig diff --git a/composer.json b/composer.json index f815475..b3aef36 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "doctrine/doctrine-migrations-bundle": "^3.1", "doctrine/orm": "^2.8", "easycorp/easyadmin-bundle": "^3", + "sensio/framework-extra-bundle": "^6.1", "symfony/asset": "5.2.*", "symfony/console": "5.2.*", "symfony/dotenv": "5.2.*", diff --git a/composer.lock b/composer.lock index 382b3c0..07b7beb 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "7e3415cd572563dce33ca898646a1227", + "content-hash": "4e8e54f0634c09e272233b3cc1fcf27c", "packages": [ { "name": "composer/package-versions-deprecated", @@ -2217,6 +2217,84 @@ }, "time": "2020-03-23T09:12:05+00:00" }, + { + "name": "sensio/framework-extra-bundle", + "version": "v6.1.2", + "source": { + "type": "git", + "url": "https://github.com/sensiolabs/SensioFrameworkExtraBundle.git", + "reference": "676262b7a65a1033befbcf59e180d072df7504b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/676262b7a65a1033befbcf59e180d072df7504b6", + "reference": "676262b7a65a1033befbcf59e180d072df7504b6", + "shasum": "" + }, + "require": { + "doctrine/annotations": "^1.0", + "php": ">=7.2.5", + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/framework-bundle": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0" + }, + "conflict": { + "doctrine/doctrine-cache-bundle": "<1.3.1", + "doctrine/persistence": "<1.3" + }, + "require-dev": { + "doctrine/dbal": "^2.10|^3.0", + "doctrine/doctrine-bundle": "^1.11|^2.0", + "doctrine/orm": "^2.5", + "symfony/browser-kit": "^4.4|^5.0", + "symfony/doctrine-bridge": "^4.4|^5.0", + "symfony/dom-crawler": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/finder": "^4.4|^5.0", + "symfony/monolog-bridge": "^4.0|^5.0", + "symfony/monolog-bundle": "^3.2", + "symfony/phpunit-bridge": "^4.4.9|^5.0.9", + "symfony/security-bundle": "^4.4|^5.0", + "symfony/twig-bundle": "^4.4|^5.0", + "symfony/yaml": "^4.4|^5.0", + "twig/twig": "^1.34|^2.4|^3.0" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "6.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Sensio\\Bundle\\FrameworkExtraBundle\\": "src/" + }, + "exclude-from-classmap": [ + "/tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "This bundle provides a way to configure your controllers with annotations", + "keywords": [ + "annotations", + "controllers" + ], + "support": { + "issues": "https://github.com/sensiolabs/SensioFrameworkExtraBundle/issues", + "source": "https://github.com/sensiolabs/SensioFrameworkExtraBundle/tree/v6.1.2" + }, + "time": "2021-04-09T16:14:11+00:00" + }, { "name": "symfony/asset", "version": "v5.2.4", diff --git a/config/bundles.php b/config/bundles.php index 079b827..abe9596 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -14,4 +14,5 @@ return [ SymfonyCasts\Bundle\VerifyEmail\SymfonyCastsVerifyEmailBundle::class => ['all' => true], EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true], Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], + Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], ]; diff --git a/config/packages/sensio_framework_extra.yaml b/config/packages/sensio_framework_extra.yaml new file mode 100644 index 0000000..1821ccc --- /dev/null +++ b/config/packages/sensio_framework_extra.yaml @@ -0,0 +1,3 @@ +sensio_framework_extra: + router: + annotations: false diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index a3101d6..279284f 100644 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -77,10 +77,10 @@ class AppController extends AbstractController } #[Route('/offer/{id}', name: 'show_offer')] - public function offer(): Response + public function show_offer(Offering $offering): Response { return $this->render('app/offer.html.twig', [ - 'offer' => $this->getOffering(), + 'offer' => $offering, ]); } } diff --git a/src/Entity/Offering.php b/src/Entity/Offering.php index 30f3cc8..9aa13bc 100644 --- a/src/Entity/Offering.php +++ b/src/Entity/Offering.php @@ -127,4 +127,9 @@ class Offering return $this; } + + public function __toString(): string + { + return (string) $this-getTitle(); + } } diff --git a/symfony.lock b/symfony.lock index 4a3072b..1ce1da6 100644 --- a/symfony.lock +++ b/symfony.lock @@ -124,6 +124,18 @@ "psr/log": { "version": "1.1.3" }, + "sensio/framework-extra-bundle": { + "version": "5.2", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "5.2", + "ref": "fb7e19da7f013d0d422fa9bce16f5c510e27609b" + }, + "files": [ + "config/packages/sensio_framework_extra.yaml" + ] + }, "symfony/asset": { "version": "v5.2.4" }, diff --git a/templates/app/index.html.twig b/templates/app/index.html.twig index 881c486..b8b3fbc 100644 --- a/templates/app/index.html.twig +++ b/templates/app/index.html.twig @@ -12,7 +12,7 @@ {% if offerings|length > 0 %}
{% for offering in offerings %} - +
{% if offering.photoFilename %} diff --git a/templates/app/offer.html.twig b/templates/app/offer.html.twig new file mode 100644 index 0000000..ef68c8e --- /dev/null +++ b/templates/app/offer.html.twig @@ -0,0 +1,21 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

{{ offer.title }}

+ +
+ Generic placeholder image +
+

+ Description +

+

+ {{ offer.description }} +

+

+ From +

+

{{ offer.byUser }} in {{ offer.zipCode }}

+
+
+{% endblock %} \ No newline at end of file