diff --git a/.gitignore b/.gitignore index 4daae38..61061d6 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,10 @@ /public/assets/ /assets/vendor/ ###< symfony/asset-mapper ### + +/public/favicon.ico +/public/favicons +/public/workbox +/public/site.webmanifest +/public/site.*.webmanifest +/public/sw.js diff --git a/README.md b/README.md index 2e92290..9a6ffe6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + # Symfony + PWA = 💕 ## Introduction diff --git a/composer.lock b/composer.lock index ca449f2..c29f122 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "api-platform/core", - "version": "v3.2.20", + "version": "v3.2.21", "source": { "type": "git", "url": "https://github.com/api-platform/core.git", - "reference": "875cc155e556541c0591b0c182ed64dcc41b9984" + "reference": "195ff52c3a1948a8339855f3199b8a51d9cf6c2a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/api-platform/core/zipball/875cc155e556541c0591b0c182ed64dcc41b9984", - "reference": "875cc155e556541c0591b0c182ed64dcc41b9984", + "url": "https://api.github.com/repos/api-platform/core/zipball/195ff52c3a1948a8339855f3199b8a51d9cf6c2a", + "reference": "195ff52c3a1948a8339855f3199b8a51d9cf6c2a", "shasum": "" }, "require": { @@ -44,6 +44,7 @@ "elasticsearch/elasticsearch": ">=8.0,<8.4", "phpspec/prophecy": "<1.15", "phpunit/phpunit": "<9.5", + "symfony/framework-bundle": "6.4.6 || 7.0.6", "symfony/var-exporter": "<6.1.1" }, "require-dev": { @@ -168,9 +169,9 @@ ], "support": { "issues": "https://github.com/api-platform/core/issues", - "source": "https://github.com/api-platform/core/tree/v3.2.20" + "source": "https://github.com/api-platform/core/tree/v3.2.21" }, - "time": "2024-04-03T15:33:10+00:00" + "time": "2024-04-13T07:16:02+00:00" }, { "name": "composer/semver", @@ -348,16 +349,16 @@ }, { "name": "doctrine/collections", - "version": "2.2.1", + "version": "2.2.2", "source": { "type": "git", "url": "https://github.com/doctrine/collections.git", - "reference": "420480fc085bc65f3c956af13abe8e7546f94813" + "reference": "d8af7f248c74f195f7347424600fd9e17b57af59" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/collections/zipball/420480fc085bc65f3c956af13abe8e7546f94813", - "reference": "420480fc085bc65f3c956af13abe8e7546f94813", + "url": "https://api.github.com/repos/doctrine/collections/zipball/d8af7f248c74f195f7347424600fd9e17b57af59", + "reference": "d8af7f248c74f195f7347424600fd9e17b57af59", "shasum": "" }, "require": { @@ -414,7 +415,7 @@ ], "support": { "issues": "https://github.com/doctrine/collections/issues", - "source": "https://github.com/doctrine/collections/tree/2.2.1" + "source": "https://github.com/doctrine/collections/tree/2.2.2" }, "funding": [ { @@ -430,20 +431,20 @@ "type": "tidelift" } ], - "time": "2024-03-05T22:28:45+00:00" + "time": "2024-04-18T06:56:21+00:00" }, { "name": "doctrine/dbal", - "version": "3.8.3", + "version": "3.8.4", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "db922ba9436b7b18a23d1653a0b41ff2369ca41c" + "reference": "b05e48a745f722801f55408d0dbd8003b403dbbd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/db922ba9436b7b18a23d1653a0b41ff2369ca41c", - "reference": "db922ba9436b7b18a23d1653a0b41ff2369ca41c", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/b05e48a745f722801f55408d0dbd8003b403dbbd", + "reference": "b05e48a745f722801f55408d0dbd8003b403dbbd", "shasum": "" }, "require": { @@ -527,7 +528,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.8.3" + "source": "https://github.com/doctrine/dbal/tree/3.8.4" }, "funding": [ { @@ -543,7 +544,7 @@ "type": "tidelift" } ], - "time": "2024-03-03T15:55:06+00:00" + "time": "2024-04-25T07:04:44+00:00" }, { "name": "doctrine/deprecations", @@ -1236,16 +1237,16 @@ }, { "name": "doctrine/orm", - "version": "3.1.1", + "version": "3.1.2", "source": { "type": "git", "url": "https://github.com/doctrine/orm.git", - "reference": "9c560713925ac5859342e6ff370c4c997acf2fd4" + "reference": "f79d166a4e844beb9389f23bdb44abdbf58cec38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/orm/zipball/9c560713925ac5859342e6ff370c4c997acf2fd4", - "reference": "9c560713925ac5859342e6ff370c4c997acf2fd4", + "url": "https://api.github.com/repos/doctrine/orm/zipball/f79d166a4e844beb9389f23bdb44abdbf58cec38", + "reference": "f79d166a4e844beb9389f23bdb44abdbf58cec38", "shasum": "" }, "require": { @@ -1318,9 +1319,9 @@ ], "support": { "issues": "https://github.com/doctrine/orm/issues", - "source": "https://github.com/doctrine/orm/tree/3.1.1" + "source": "https://github.com/doctrine/orm/tree/3.1.2" }, - "time": "2024-03-21T11:37:52+00:00" + "time": "2024-04-15T14:20:40+00:00" }, { "name": "doctrine/persistence", @@ -1549,16 +1550,16 @@ }, { "name": "monolog/monolog", - "version": "3.5.0", + "version": "3.6.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "c915e2634718dbc8a4a15c61b0e62e7a44e14448" + "reference": "4b18b21a5527a3d5ffdac2fd35d3ab25a9597654" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/c915e2634718dbc8a4a15c61b0e62e7a44e14448", - "reference": "c915e2634718dbc8a4a15c61b0e62e7a44e14448", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/4b18b21a5527a3d5ffdac2fd35d3ab25a9597654", + "reference": "4b18b21a5527a3d5ffdac2fd35d3ab25a9597654", "shasum": "" }, "require": { @@ -1581,7 +1582,7 @@ "phpstan/phpstan": "^1.9", "phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-strict-rules": "^1.4", - "phpunit/phpunit": "^10.1", + "phpunit/phpunit": "^10.5.17", "predis/predis": "^1.1 || ^2", "ruflin/elastica": "^7", "symfony/mailer": "^5.4 || ^6", @@ -1634,7 +1635,7 @@ ], "support": { "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/3.5.0" + "source": "https://github.com/Seldaek/monolog/tree/3.6.0" }, "funding": [ { @@ -1646,7 +1647,7 @@ "type": "tidelift" } ], - "time": "2023-10-27T15:32:31+00:00" + "time": "2024-04-12T21:02:21+00:00" }, { "name": "nelmio/cors-bundle", @@ -1765,28 +1766,35 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.3.0", + "version": "5.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" + "reference": "298d2febfe79d03fe714eb871d5538da55205b1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/298d2febfe79d03fe714eb871d5538da55205b1a", + "reference": "298d2febfe79d03fe714eb871d5538da55205b1a", "shasum": "" }, "require": { + "doctrine/deprecations": "^1.1", "ext-filter": "*", - "php": "^7.2 || ^8.0", + "php": "^7.4 || ^8.0", "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", + "phpdocumentor/type-resolver": "^1.7", + "phpstan/phpdoc-parser": "^1.7", "webmozart/assert": "^1.9.1" }, "require-dev": { - "mockery/mockery": "~1.3.2", - "psalm/phar": "^4.8" + "mockery/mockery": "~1.3.5", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-webmozart-assert": "^1.2", + "phpunit/phpunit": "^9.5", + "vimeo/psalm": "^5.13" }, "type": "library", "extra": { @@ -1810,15 +1818,15 @@ }, { "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" + "email": "opensource@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.0" }, - "time": "2021-10-19T17:43:47+00:00" + "time": "2024-04-09T21:13:58+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -2237,12 +2245,12 @@ "source": { "type": "git", "url": "https://github.com/Spomky-Labs/pwa-bundle.git", - "reference": "dc34dc1a7ce887802790836607f8b67a1f8705b3" + "reference": "83644b7dbeafef517d63b0801035cacc3bf6f819" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Spomky-Labs/pwa-bundle/zipball/dc34dc1a7ce887802790836607f8b67a1f8705b3", - "reference": "dc34dc1a7ce887802790836607f8b67a1f8705b3", + "url": "https://api.github.com/repos/Spomky-Labs/pwa-bundle/zipball/83644b7dbeafef517d63b0801035cacc3bf6f819", + "reference": "83644b7dbeafef517d63b0801035cacc3bf6f819", "shasum": "" }, "require": { @@ -2260,17 +2268,24 @@ }, "require-dev": { "dbrekelmans/bdi": "^1.1", + "ekino/phpstan-banned-code": "^1.0", + "ergebnis/phpunit-slow-test-detector": "^2.14", + "ext-sockets": "*", "infection/infection": "^0.28", + "matthiasnoback/symfony-config-test": "^5.1", + "php-parallel-lint/php-parallel-lint": "^1.4", "phpstan/extension-installer": "^1.1", "phpstan/phpdoc-parser": "^1.28", "phpstan/phpstan": "^1.0", "phpstan/phpstan-beberlei-assert": "^1.0", "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-phpunit": "^1.0", + "phpstan/phpstan-phpunit": "^1.3", "phpstan/phpstan-strict-rules": "^1.0", + "phpstan/phpstan-symfony": "^1.3", "phpunit/phpunit": "^10.1|^11.0", "rector/rector": "^1.0", "staabm/phpstan-todo-by": "^0.1.25", + "struggle-for-php/sfp-phpstan-psr-log": "^0.20.0", "symfony/filesystem": "^6.4|^7.0", "symfony/framework-bundle": "^6.4|^7.0", "symfony/mime": "^6.4|^7.0", @@ -2340,7 +2355,7 @@ "type": "patreon" } ], - "time": "2024-04-07T16:11:20+00:00" + "time": "2024-04-29T06:00:34+00:00" }, { "name": "symfony/asset", @@ -3814,16 +3829,16 @@ }, { "name": "symfony/framework-bundle", - "version": "v7.0.6", + "version": "v7.0.4", "source": { "type": "git", "url": "https://github.com/symfony/framework-bundle.git", - "reference": "5ebf6771f92d135c2bdbda7133998feb74713658" + "reference": "b58bcb2f9c32405b8fbaa24a1e38c8a10bad7b21" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/framework-bundle/zipball/5ebf6771f92d135c2bdbda7133998feb74713658", - "reference": "5ebf6771f92d135c2bdbda7133998feb74713658", + "url": "https://api.github.com/repos/symfony/framework-bundle/zipball/b58bcb2f9c32405b8fbaa24a1e38c8a10bad7b21", + "reference": "b58bcb2f9c32405b8fbaa24a1e38c8a10bad7b21", "shasum": "" }, "require": { @@ -3940,7 +3955,7 @@ "description": "Provides a tight integration between Symfony components and the Symfony full-stack framework", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/framework-bundle/tree/v7.0.6" + "source": "https://github.com/symfony/framework-bundle/tree/v7.0.4" }, "funding": [ { @@ -3956,7 +3971,7 @@ "type": "tidelift" } ], - "time": "2024-03-27T19:55:25+00:00" + "time": "2024-02-26T07:52:39+00:00" }, { "name": "symfony/http-client", @@ -6253,16 +6268,16 @@ }, { "name": "symfony/stimulus-bundle", - "version": "v2.16.0", + "version": "v2.17.0", "source": { "type": "git", "url": "https://github.com/symfony/stimulus-bundle.git", - "reference": "6add4bdab1b9df4f2b2532a9dcb7b2f26dbba634" + "reference": "b828a32fe9f75500d26b563cc01874657162c413" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stimulus-bundle/zipball/6add4bdab1b9df4f2b2532a9dcb7b2f26dbba634", - "reference": "6add4bdab1b9df4f2b2532a9dcb7b2f26dbba634", + "url": "https://api.github.com/repos/symfony/stimulus-bundle/zipball/b828a32fe9f75500d26b563cc01874657162c413", + "reference": "b828a32fe9f75500d26b563cc01874657162c413", "shasum": "" }, "require": { @@ -6272,7 +6287,7 @@ "symfony/deprecation-contracts": "^2.0|^3.0", "symfony/finder": "^5.4|^6.0|^7.0", "symfony/http-kernel": "^5.4|^6.0|^7.0", - "twig/twig": "^2.15.3|~3.8.0" + "twig/twig": "^2.15.3|^3.8" }, "require-dev": { "symfony/asset-mapper": "^6.3|^7.0", @@ -6302,7 +6317,7 @@ "symfony-ux" ], "support": { - "source": "https://github.com/symfony/stimulus-bundle/tree/v2.16.0" + "source": "https://github.com/symfony/stimulus-bundle/tree/v2.17.0" }, "funding": [ { @@ -6318,7 +6333,7 @@ "type": "tidelift" } ], - "time": "2024-02-29T16:20:46+00:00" + "time": "2024-04-21T10:23:35+00:00" }, { "name": "symfony/stopwatch", @@ -7369,34 +7384,34 @@ }, { "name": "twig/extra-bundle", - "version": "v3.8.0", + "version": "v3.9.3", "source": { "type": "git", "url": "https://github.com/twigphp/twig-extra-bundle.git", - "reference": "32807183753de0388c8e59f7ac2d13bb47311140" + "reference": "ef6869adf1fdab66f7e495771a7ba01496ffc0d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/twig-extra-bundle/zipball/32807183753de0388c8e59f7ac2d13bb47311140", - "reference": "32807183753de0388c8e59f7ac2d13bb47311140", + "url": "https://api.github.com/repos/twigphp/twig-extra-bundle/zipball/ef6869adf1fdab66f7e495771a7ba01496ffc0d5", + "reference": "ef6869adf1fdab66f7e495771a7ba01496ffc0d5", "shasum": "" }, "require": { "php": ">=7.2.5", - "symfony/framework-bundle": "^5.4|^6.0|^7.0", - "symfony/twig-bundle": "^5.4|^6.0|^7.0", + "symfony/framework-bundle": "^5.4|^6.4|^7.0", + "symfony/twig-bundle": "^5.4|^6.4|^7.0", "twig/twig": "^3.0" }, "require-dev": { "league/commonmark": "^1.0|^2.0", "symfony/phpunit-bridge": "^6.4|^7.0", "twig/cache-extra": "^3.0", - "twig/cssinliner-extra": "^2.12|^3.0", - "twig/html-extra": "^2.12|^3.0", - "twig/inky-extra": "^2.12|^3.0", - "twig/intl-extra": "^2.12|^3.0", - "twig/markdown-extra": "^2.12|^3.0", - "twig/string-extra": "^2.12|^3.0" + "twig/cssinliner-extra": "^3.0", + "twig/html-extra": "^3.0", + "twig/inky-extra": "^3.0", + "twig/intl-extra": "^3.0", + "twig/markdown-extra": "^3.0", + "twig/string-extra": "^3.0" }, "type": "symfony-bundle", "autoload": { @@ -7427,7 +7442,7 @@ "twig" ], "support": { - "source": "https://github.com/twigphp/twig-extra-bundle/tree/v3.8.0" + "source": "https://github.com/twigphp/twig-extra-bundle/tree/v3.9.3" }, "funding": [ { @@ -7439,34 +7454,41 @@ "type": "tidelift" } ], - "time": "2023-11-21T14:02:01+00:00" + "time": "2024-04-18T09:24:21+00:00" }, { "name": "twig/twig", - "version": "v3.8.0", + "version": "v3.9.3", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d" + "reference": "a842d75fed59cdbcbd3a3ad7fb9eb768fc350d58" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/9d15f0ac07f44dc4217883ec6ae02fd555c6f71d", - "reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/a842d75fed59cdbcbd3a3ad7fb9eb768fc350d58", + "reference": "a842d75fed59cdbcbd3a3ad7fb9eb768fc350d58", "shasum": "" }, "require": { "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-mbstring": "^1.3", "symfony/polyfill-php80": "^1.22" }, "require-dev": { "psr/container": "^1.0|^2.0", - "symfony/phpunit-bridge": "^5.4.9|^6.3|^7.0" + "symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0" }, "type": "library", "autoload": { + "files": [ + "src/Resources/core.php", + "src/Resources/debug.php", + "src/Resources/escaper.php", + "src/Resources/string_loader.php" + ], "psr-4": { "Twig\\": "src/" } @@ -7499,7 +7521,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.8.0" + "source": "https://github.com/twigphp/Twig/tree/v3.9.3" }, "funding": [ { @@ -7511,7 +7533,7 @@ "type": "tidelift" } ], - "time": "2023-11-21T18:54:41+00:00" + "time": "2024-04-18T11:59:33+00:00" }, { "name": "webmozart/assert", @@ -9707,16 +9729,16 @@ }, { "name": "symfony/maker-bundle", - "version": "v1.58.0", + "version": "v1.59.0", "source": { "type": "git", "url": "https://github.com/symfony/maker-bundle.git", - "reference": "c4f8d2c5d55950e1a49e822efc83a8511bee8a36" + "reference": "1f02b59b98003b2c1f51bc8f178aee5cbf36779c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/maker-bundle/zipball/c4f8d2c5d55950e1a49e822efc83a8511bee8a36", - "reference": "c4f8d2c5d55950e1a49e822efc83a8511bee8a36", + "url": "https://api.github.com/repos/symfony/maker-bundle/zipball/1f02b59b98003b2c1f51bc8f178aee5cbf36779c", + "reference": "1f02b59b98003b2c1f51bc8f178aee5cbf36779c", "shasum": "" }, "require": { @@ -9779,7 +9801,7 @@ ], "support": { "issues": "https://github.com/symfony/maker-bundle/issues", - "source": "https://github.com/symfony/maker-bundle/tree/v1.58.0" + "source": "https://github.com/symfony/maker-bundle/tree/v1.59.0" }, "funding": [ { @@ -9795,7 +9817,7 @@ "type": "tidelift" } ], - "time": "2024-04-06T15:08:12+00:00" + "time": "2024-04-27T21:12:25+00:00" }, { "name": "symfony/panther", diff --git a/config/packages/pwa.yaml b/config/packages/pwa.yaml index e00d9cb..25a5ed0 100644 --- a/config/packages/pwa.yaml +++ b/config/packages/pwa.yaml @@ -1,18 +1,24 @@ pwa: image_processor: 'pwa.image_processor.imagick' +# user_agent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36' + favicons: + enabled: true + src: "images/todo.svg" + tile_color: "#c026d3" manifest: enabled: true + public_url: '/site.{locale}.webmanifest' background_color: "#c026d3" theme_color: "#c026d3" - name: 'Simple TODO App' - short_name: 'Todo App' - description: 'A simple TODO application build using Symfony and PHPWA' + name: 'app.name' + short_name: 'app.short_name' + description: 'app.description' orientation: "any" display: "standalone" scope: "/" display_override: ['fullscreen', 'minimal-ui', 'window-controls-overlay'] id: "/" - start_url: "/" + start_url: "app.start_url" icons: - src: "images/todo.svg" sizes: "any" @@ -37,7 +43,7 @@ pwa: max_age: 60 max_entries: 30 preload_urls: - - '@homepage' + - '@static_pages' strategy: 'NetworkFirst' broadcast: true range_requests: true @@ -51,7 +57,10 @@ pwa: - 'api_entrypoint' - '_api_/items{._format}_get_collection' offline_fallback: - page: 'app_homepage' + page: + path: 'app_homepage' + params: + _locale: 'en_US' background_sync: - queue_name: 'items' match_callback: 'startsWith: /items/' diff --git a/config/packages/translation.yaml b/config/packages/translation.yaml index b3f8f9c..23b2cf5 100644 --- a/config/packages/translation.yaml +++ b/config/packages/translation.yaml @@ -1,7 +1,10 @@ framework: - default_locale: en + set_locale_from_accept_language: true + set_content_language_from_locale: true + enabled_locales: '%app.supported_locales%' + default_locale: '%app.default_locale%' translator: default_path: '%kernel.project_dir%/translations' fallbacks: - - en - providers: + - en_US + providers: ~ diff --git a/config/services.yaml b/config/services.yaml index 2d6a76f..9ecf1e8 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -4,6 +4,10 @@ # Put parameters here that don't need to change on each machine where the app is deployed # https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration parameters: + locale: 'en-US' + app.default_locale: 'en-US' + app.supported_locales: ['en_US', 'fr_FR'] + app.supported_locales_regex: 'en_US|fr_FR' services: # default configuration for services in *this* file @@ -22,3 +26,6 @@ services: # add more service definitions when explicit configuration is needed # please note that last definitions always *replace* previous ones + + App\PreloadGenerator\StaticPagesUrlPreloadGenerator: + tags: ['spomky_labs_pwa.preload_urls_generator'] diff --git a/public/favicon.ico b/public/favicon.ico deleted file mode 100644 index 66dbcde..0000000 Binary files a/public/favicon.ico and /dev/null differ diff --git a/src/Controller/HomepageController.php b/src/Controller/HomepageController.php index 423c3db..2b90a11 100644 --- a/src/Controller/HomepageController.php +++ b/src/Controller/HomepageController.php @@ -8,8 +8,8 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; -use SpomkyLabs\PwaBundle\Attribute\PreloadUrl; +#[Route('/{_locale<%app.supported_locales_regex%>}')] class HomepageController extends AbstractController { public function __construct( @@ -17,9 +17,6 @@ public function __construct( private readonly ItemRepository $itemRepository, ){} - #[PreloadUrl(alias: 'homepage', params: ['_locale' => 'fr'])] - #[PreloadUrl(alias: 'homepage', params: ['_locale' => 'en'])] - #[PreloadUrl(alias: 'homepage', params: ['_locale' => 'it'])] #[Route('/', name: 'app_homepage', methods: [Request::METHOD_GET])] public function homepage(): Response { @@ -34,42 +31,4 @@ public function homepage(): Response return $response; } - - #[Route('/add', name: 'app_add_item', methods: [Request::METHOD_POST])] - public function addItem(Request $request): Response - { - $form = $this->itemHandler->prepare(); - $item = $this->itemHandler->handle($form, $request); - if ($item !== null) { - $this->addFlash('success', 'Item added'); - return $this->redirectToRoute('app_homepage'); - } - $this->addFlash('error', 'Item not added'); - return $this->redirectToRoute('app_homepage'); - } - - #[Route('/items/{id}/toggle', name: 'app_toggle', methods: [Request::METHOD_POST])] - public function toggle(string $id): Response - { - $item = $this->itemRepository->findOneById($id); - if ($item !== null) { - $item->toggle(); - $this->itemRepository->save($item); - } - $this->addFlash('success', 'Item state changed'); - - return $this->redirectToRoute('app_homepage'); - } - - #[Route('/items/{id}/remove', name: 'app_remove', methods: [Request::METHOD_POST])] - public function remove(string $id): Response - { - $item = $this->itemRepository->findOneById($id); - if ($item !== null) { - $this->itemRepository->remove($item); - } - $this->addFlash('success', 'Item removed'); - - return $this->redirectToRoute('app_homepage'); - } } diff --git a/src/Controller/ItemController.php b/src/Controller/ItemController.php new file mode 100644 index 0000000..70f8abe --- /dev/null +++ b/src/Controller/ItemController.php @@ -0,0 +1,56 @@ +itemHandler->prepare(); + $item = $this->itemHandler->handle($form, $request); + if ($item !== null) { + $this->addFlash('success', 'Item added'); + return $this->redirectToRoute('app_homepage'); + } + $this->addFlash('error', 'Item not added'); + return $this->redirectToRoute('app_homepage'); + } + + #[Route('/items/{id}/toggle', name: 'app_toggle', methods: [Request::METHOD_POST])] + public function toggle(string $id): Response + { + $item = $this->itemRepository->findOneById($id); + if ($item !== null) { + $item->toggle(); + $this->itemRepository->save($item); + } + $this->addFlash('success', 'Item state changed'); + + return $this->redirectToRoute('app_homepage'); + } + + #[Route('/items/{id}/remove', name: 'app_remove', methods: [Request::METHOD_POST])] + public function remove(string $id): Response + { + $item = $this->itemRepository->findOneById($id); + if ($item !== null) { + $this->itemRepository->remove($item); + } + $this->addFlash('success', 'Item removed'); + + return $this->redirectToRoute('app_homepage'); + } +} diff --git a/src/Controller/RootController.php b/src/Controller/RootController.php new file mode 100644 index 0000000..8cc3dc3 --- /dev/null +++ b/src/Controller/RootController.php @@ -0,0 +1,38 @@ +attributes->get('_locale') ?? + $request->getSession() + ->get('_locale') ?? + $request->getPreferredLanguage($this->supportedLocales) ?? + $this->defaultLocale + ; + + return $this->redirectToRoute('app_homepage', [ + '_locale' => $locale, + ], Response::HTTP_SEE_OTHER); + } +} diff --git a/src/PreloadGenerator/StaticPagesUrlPreloadGenerator.php b/src/PreloadGenerator/StaticPagesUrlPreloadGenerator.php new file mode 100644 index 0000000..f365969 --- /dev/null +++ b/src/PreloadGenerator/StaticPagesUrlPreloadGenerator.php @@ -0,0 +1,36 @@ + + */ + public function generateUrls(): iterable + { + foreach ($this->locales as $locale) { + yield Url::create( + 'app_homepage', + [ + '_locale' => $locale, + ] + ); + } + } +} diff --git a/templates/base.html.twig b/templates/base.html.twig index 83f74c1..0144989 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -12,7 +12,7 @@ {% block javascripts %} {% block importmap %}{{ importmap('app') }}{% endblock %} {% endblock %} - {{ pwa() }} + {{ pwa(locale=app.request.locale) }}
{% block content %} diff --git a/translations/messages+intl-icu.en_US.xlf b/translations/messages+intl-icu.en_US.xlf new file mode 100644 index 0000000..9a12806 --- /dev/null +++ b/translations/messages+intl-icu.en_US.xlf @@ -0,0 +1,178 @@ + +