From 6172d76b79c0ff271055815d791553a500ac29e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20P=C5=82aczek?= Date: Sat, 19 Oct 2024 17:34:00 +0200 Subject: [PATCH] Installed and used `composer require knplabs/knp-time-bundle` to render time since ship arrived at. --- composer.json | 1 + composer.lock | 171 +++++++++++++++++++++++++- config/bundles.php | 1 + config/packages/translation.yaml | 7 ++ src/Repository/StarshipRepository.php | 24 ++-- symfony.lock | 16 +++ templates/main/homepage.html.twig | 2 +- translations/.gitignore | 0 8 files changed, 208 insertions(+), 14 deletions(-) create mode 100644 config/packages/translation.yaml create mode 100644 translations/.gitignore diff --git a/composer.json b/composer.json index 1c4ad32..dd94b12 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,7 @@ "php": ">=8.2", "ext-ctype": "*", "ext-iconv": "*", + "knplabs/knp-time-bundle": "^2.4", "php-cs-fixer/shim": "^3.64", "phpdocumentor/reflection-docblock": "^5.4", "phpstan/phpdoc-parser": "^1.33", diff --git a/composer.lock b/composer.lock index d5f9b59..d56cc70 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": "af30e845fe4eb922d99c09917c25558f", + "content-hash": "9adfba642a39cd4247f2862fcd13dded", "packages": [ { "name": "composer/semver", @@ -134,6 +134,81 @@ }, "time": "2024-01-30T19:34:25+00:00" }, + { + "name": "knplabs/knp-time-bundle", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/KnpLabs/KnpTimeBundle.git", + "reference": "93e9528415b28a19872d74b28e816045c0fd217b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/KnpLabs/KnpTimeBundle/zipball/93e9528415b28a19872d74b28e816045c0fd217b", + "reference": "93e9528415b28a19872d74b28e816045c0fd217b", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/config": "^5.4|^6.0|^7.0", + "symfony/dependency-injection": "^5.4|^6.0|^7.0", + "symfony/translation": "^5.4|^6.0|^7.0" + }, + "conflict": { + "phpunit/phpunit": "<8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.11", + "phpunit/phpunit": "^9.6", + "symfony/framework-bundle": "^5.4|^6.0|^7.0", + "symfony/phpunit-bridge": "^5.4|^6.0|^7.0", + "symfony/twig-bundle": "^5.4|^6.0|^7.0" + }, + "suggest": { + "symfony/twig-bundle": "to use the Twig `time_diff()` function and `|time_diff`/`|duration` filter" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Knp\\Bundle\\TimeBundle\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "KnpLabs Team", + "homepage": "https://knplabs.com" + }, + { + "name": "Symfony Community", + "homepage": "https://github.com/KnpLabs/KnpTimeBundle/contributors" + } + ], + "description": "Making your dates and durations look sensible and descriptive", + "homepage": "https://github.com/KnpLabs/KnpTimeBundle", + "keywords": [ + "bundle", + "date", + "descriptive time", + "duration", + "knp", + "knplabs", + "time" + ], + "support": { + "issues": "https://github.com/KnpLabs/KnpTimeBundle/issues", + "source": "https://github.com/KnpLabs/KnpTimeBundle/tree/v2.4.0" + }, + "time": "2024-06-11T09:38:28+00:00" + }, { "name": "monolog/monolog", "version": "3.7.0", @@ -3553,6 +3628,100 @@ ], "time": "2024-09-20T08:28:38+00:00" }, + { + "name": "symfony/translation", + "version": "v7.1.5", + "source": { + "type": "git", + "url": "https://github.com/symfony/translation.git", + "reference": "235535e3f84f3dfbdbde0208ede6ca75c3a489ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/translation/zipball/235535e3f84f3dfbdbde0208ede6ca75c3a489ea", + "reference": "235535e3f84f3dfbdbde0208ede6ca75c3a489ea", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-mbstring": "~1.0", + "symfony/translation-contracts": "^2.5|^3.0" + }, + "conflict": { + "symfony/config": "<6.4", + "symfony/console": "<6.4", + "symfony/dependency-injection": "<6.4", + "symfony/http-client-contracts": "<2.5", + "symfony/http-kernel": "<6.4", + "symfony/service-contracts": "<2.5", + "symfony/twig-bundle": "<6.4", + "symfony/yaml": "<6.4" + }, + "provide": { + "symfony/translation-implementation": "2.3|3.0" + }, + "require-dev": { + "nikic/php-parser": "^4.18|^5.0", + "psr/log": "^1|^2|^3", + "symfony/config": "^6.4|^7.0", + "symfony/console": "^6.4|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/finder": "^6.4|^7.0", + "symfony/http-client-contracts": "^2.5|^3.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/intl": "^6.4|^7.0", + "symfony/polyfill-intl-icu": "^1.21", + "symfony/routing": "^6.4|^7.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/yaml": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\Translation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools to internationalize your application", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/translation/tree/v7.1.5" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-16T06:30:38+00:00" + }, { "name": "symfony/translation-contracts", "version": "v3.5.0", diff --git a/config/bundles.php b/config/bundles.php index cd1f8f0..f40b212 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -11,4 +11,5 @@ return [ Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true], Symfony\UX\Turbo\TurboBundle::class => ['all' => true], Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], + Knp\Bundle\TimeBundle\KnpTimeBundle::class => ['all' => true], ]; diff --git a/config/packages/translation.yaml b/config/packages/translation.yaml new file mode 100644 index 0000000..b3f8f9c --- /dev/null +++ b/config/packages/translation.yaml @@ -0,0 +1,7 @@ +framework: + default_locale: en + translator: + default_path: '%kernel.project_dir%/translations' + fallbacks: + - en + providers: diff --git a/src/Repository/StarshipRepository.php b/src/Repository/StarshipRepository.php index 0b3d78a..1a2bd1e 100644 --- a/src/Repository/StarshipRepository.php +++ b/src/Repository/StarshipRepository.php @@ -17,18 +17,18 @@ class StarshipRepository $this->logger->info('Starship Repository: Finding Starships'); return [ - new Starship(1, 'Starship 01', 'Heavy Starship', 'Human Captain', StarshipStatusEnum::COMPLETED, new \DateTimeImmutable()), - new Starship(2, 'Starship 02', 'Light Starship', 'Robot Captain', StarshipStatusEnum::IN_PROGRESS, new \DateTimeImmutable()), - new Starship(3, 'USS Voyager', 'Intrepid', 'Kathryn Janeway', StarshipStatusEnum::WAITING, new \DateTimeImmutable()), - new Starship(4, 'Starblade', 'Interceptor', 'Lance Stellar', StarshipStatusEnum::COMPLETED, new \DateTimeImmutable()), - new Starship(5, 'Black Star', 'Battlecruiser', 'Zara Nox', StarshipStatusEnum::WAITING, new \DateTimeImmutable()), - new Starship(6, 'SS Horizon', 'Explorer', 'James Marshall', StarshipStatusEnum::COMPLETED, new \DateTimeImmutable()), - new Starship(7, 'Nebula Queen', 'Transport', 'Elara Trent', StarshipStatusEnum::IN_PROGRESS, new \DateTimeImmutable()), - new Starship(8, 'Celestial Wave', 'Frigate', 'Talon Skye', StarshipStatusEnum::IN_PROGRESS, new \DateTimeImmutable()), - new Starship(9, 'Galactic Serpent', 'Destroyer', 'Viktor Helios', StarshipStatusEnum::COMPLETED, new \DateTimeImmutable()), - new Starship(10, 'Phoenix Wing', 'Carrier', 'Aurora Drake', StarshipStatusEnum::COMPLETED, new \DateTimeImmutable()), - new Starship(11, 'Silver Comet', 'Scout', 'Finn O\'Neil', StarshipStatusEnum::WAITING, new \DateTimeImmutable()), - new Starship(12, 'Crimson Spear', 'Corvette', 'Raven Callen', StarshipStatusEnum::IN_PROGRESS, new \DateTimeImmutable()), + new Starship(1, 'Starship 01', 'Heavy Starship', 'Human Captain', StarshipStatusEnum::COMPLETED, new \DateTimeImmutable('14-08-1999 06:32')), + new Starship(2, 'Starship 02', 'Light Starship', 'Robot Captain', StarshipStatusEnum::IN_PROGRESS, new \DateTimeImmutable('23-11-2015 17:20')), + new Starship(3, 'USS Voyager', 'Intrepid', 'Kathryn Janeway', StarshipStatusEnum::WAITING, new \DateTimeImmutable('04-05-2007 12:45')), + new Starship(4, 'Starblade', 'Interceptor', 'Lance Stellar', StarshipStatusEnum::COMPLETED, new \DateTimeImmutable('29-03-1991 10:15')), + new Starship(5, 'Black Star', 'Battlecruiser', 'Zara Nox', StarshipStatusEnum::WAITING, new \DateTimeImmutable('18-10-2001 22:53')), + new Starship(6, 'SS Horizon', 'Explorer', 'James Marshall', StarshipStatusEnum::COMPLETED, new \DateTimeImmutable('01-07-2019 08:10')), + new Starship(7, 'Nebula Queen', 'Transport', 'Elara Trent', StarshipStatusEnum::IN_PROGRESS, new \DateTimeImmutable('15-09-1996 04:37')), + new Starship(8, 'Celestial Wave', 'Frigate', 'Talon Skye', StarshipStatusEnum::IN_PROGRESS, new \DateTimeImmutable('10-11-2023 13:55')), + new Starship(9, 'Galactic Serpent', 'Destroyer', 'Viktor Helios', StarshipStatusEnum::COMPLETED, new \DateTimeImmutable('25-04-2020 16:02')), + new Starship(10, 'Phoenix Wing', 'Carrier', 'Aurora Drake', StarshipStatusEnum::COMPLETED, new \DateTimeImmutable('30-08-2005 10:30')), + new Starship(11, 'Silver Comet', 'Scout', 'Finn O\'Neil', StarshipStatusEnum::WAITING, new \DateTimeImmutable('12-02-1995 08:45')), + new Starship(12, 'Crimson Spear', 'Corvette', 'Raven Callen', StarshipStatusEnum::IN_PROGRESS, new \DateTimeImmutable('07-01-2011 03:29')), ]; } diff --git a/symfony.lock b/symfony.lock index de53212..650018d 100644 --- a/symfony.lock +++ b/symfony.lock @@ -1,4 +1,7 @@ { + "knplabs/knp-time-bundle": { + "version": "v2.4.0" + }, "php-cs-fixer/shim": { "version": "3.64", "recipe": { @@ -129,6 +132,19 @@ "assets/controllers/hello_controller.js" ] }, + "symfony/translation": { + "version": "7.1", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "6.3", + "ref": "e28e27f53663cc34f0be2837aba18e3a1bef8e7b" + }, + "files": [ + "config/packages/translation.yaml", + "translations/.gitignore" + ] + }, "symfony/twig-bundle": { "version": "7.1", "recipe": { diff --git a/templates/main/homepage.html.twig b/templates/main/homepage.html.twig index 8723e4b..aedc4b5 100644 --- a/templates/main/homepage.html.twig +++ b/templates/main/homepage.html.twig @@ -29,7 +29,7 @@ >{{ ship.name }}
- Arrived at: {{ ship.arrivedAt|date }} + Arrived at: {{ ship.arrivedAt|ago }}
diff --git a/translations/.gitignore b/translations/.gitignore new file mode 100644 index 0000000..e69de29