diff --git a/composer.json b/composer.json index ba6dd242a982c4fc3344412dc9bc96d4a5adb6e2..573bb50de4d2383e808ecf5cc303204dfa0b09f1 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "doctrine/doctrine-migrations-bundle": "^3.1", "doctrine/orm": "^2.9", "easycorp/easyadmin-bundle": "^3.3", + "sensio/framework-extra-bundle": "^6.1", "symfony/console": "5.3.*", "symfony/dotenv": "5.3.*", "symfony/flex": "^1.3.1", @@ -21,6 +22,7 @@ "symfony/proxy-manager-bridge": "5.3.*", "symfony/runtime": "5.3.*", "symfony/twig-bundle": "5.3.*", + "symfony/validator": "5.3.*", "symfony/yaml": "5.3.*", "twig/extra-bundle": "^2.12|^3.0", "twig/twig": "^2.12|^3.0" diff --git a/composer.lock b/composer.lock index aabdbd217b39f50b2865ace417755b9f9dfa27c6..d9e5f229dbb6d0b27928336cff720291103927e6 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": "85d8958a864732d771a6e4b1fdb7f887", + "content-hash": "55db36571b3405faf90393d0e916ad59", "packages": [ { "name": "composer/package-versions-deprecated", @@ -2080,6 +2080,90 @@ }, "time": "2021-05-03T11:20:27+00:00" }, + { + "name": "sensio/framework-extra-bundle", + "version": "v6.1.5", + "source": { + "type": "git", + "url": "https://github.com/sensiolabs/SensioFrameworkExtraBundle.git", + "reference": "62c5909f49cf74dccdf50a294511cc24be2f969c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/62c5909f49cf74dccdf50a294511cc24be2f969c", + "reference": "62c5909f49cf74dccdf50a294511cc24be2f969c", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "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.5" + }, + "time": "2021-05-31T10:40:46+00:00" + }, { "name": "symfony/asset", "version": "v5.3.2", @@ -6674,6 +6758,122 @@ ], "time": "2021-06-17T12:52:32+00:00" }, + { + "name": "symfony/validator", + "version": "v5.3.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/validator.git", + "reference": "87621b2503601673b7e76aeffac3234ada8e1bf2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/validator/zipball/87621b2503601673b7e76aeffac3234ada8e1bf2", + "reference": "87621b2503601673b7e76aeffac3234ada8e1bf2", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "~1.0", + "symfony/polyfill-php80": "^1.15", + "symfony/translation-contracts": "^1.1|^2" + }, + "conflict": { + "doctrine/lexer": "<1.0.2", + "phpunit/phpunit": "<5.4.3", + "symfony/dependency-injection": "<4.4", + "symfony/expression-language": "<5.1", + "symfony/http-kernel": "<4.4", + "symfony/intl": "<4.4", + "symfony/property-info": "<5.3", + "symfony/translation": "<4.4", + "symfony/yaml": "<4.4" + }, + "require-dev": { + "doctrine/annotations": "^1.10.4", + "doctrine/cache": "^1.0|^2.0", + "egulias/email-validator": "^2.1.10|^3", + "symfony/cache": "^4.4|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/console": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/expression-language": "^5.1", + "symfony/finder": "^4.4|^5.0", + "symfony/http-client": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", + "symfony/intl": "^4.4|^5.0", + "symfony/mime": "^4.4|^5.0", + "symfony/property-access": "^4.4|^5.0", + "symfony/property-info": "^5.3", + "symfony/translation": "^4.4|^5.0", + "symfony/yaml": "^4.4|^5.0" + }, + "suggest": { + "egulias/email-validator": "Strict (RFC compliant) email validation", + "psr/cache-implementation": "For using the mapping cache.", + "symfony/config": "", + "symfony/expression-language": "For using the Expression validator and the ExpressionLanguageSyntax constraints", + "symfony/http-foundation": "", + "symfony/intl": "", + "symfony/property-access": "For accessing properties within comparison constraints", + "symfony/property-info": "To automatically add NotNull and Type constraints", + "symfony/translation": "For translating validation errors.", + "symfony/yaml": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Validator\\": "" + }, + "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 validate values", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/validator/tree/v5.3.2" + }, + "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": "2021-06-17T12:34:27+00:00" + }, { "name": "symfony/var-dumper", "version": "v5.3.2", diff --git a/config/bundles.php b/config/bundles.php index 605a5ba215927f8cea9b0f338c2f3f558ac421b4..ca331aee5d59a22f09633121298ec0fd3b3bd0a5 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -13,4 +13,5 @@ return [ Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true], Twig\Extra\TwigExtraBundle\TwigExtraBundle::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 0000000000000000000000000000000000000000..1821ccc079e911f276bd1866f6349ce54c963ebe --- /dev/null +++ b/config/packages/sensio_framework_extra.yaml @@ -0,0 +1,3 @@ +sensio_framework_extra: + router: + annotations: false diff --git a/config/packages/test/validator.yaml b/config/packages/test/validator.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1e5ab7880bf02b6c8982877393c846b9b3ca400d --- /dev/null +++ b/config/packages/test/validator.yaml @@ -0,0 +1,3 @@ +framework: + validation: + not_compromised_password: false diff --git a/config/packages/validator.yaml b/config/packages/validator.yaml new file mode 100644 index 0000000000000000000000000000000000000000..350786a13d9cc5f54e945984c0590cf37792ffcc --- /dev/null +++ b/config/packages/validator.yaml @@ -0,0 +1,8 @@ +framework: + validation: + email_validation_mode: html5 + + # Enables validator auto-mapping support. + # For instance, basic validation constraints will be inferred from Doctrine's metadata. + #auto_mapping: + # App\Entity\: [] diff --git a/src/Controller/PostController.php b/src/Controller/PostController.php new file mode 100644 index 0000000000000000000000000000000000000000..9f60b6e22d3d954d1d9c3f59dfa588e0eea463e1 --- /dev/null +++ b/src/Controller/PostController.php @@ -0,0 +1,32 @@ +render('post/index.html.twig', [ + 'posts' => $postRepository->findAll(), + ]); + } + + #[Route('/post/{id}', name: 'post_show', methods: ['GET'])] + public function show(Post $post): Response + { + return $this->render('post/show.html.twig', [ + 'post' => $post, + ]); + } + +} diff --git a/src/Form/PostType.php b/src/Form/PostType.php new file mode 100644 index 0000000000000000000000000000000000000000..1d56b8b8a0173fc5219d9d343f33d81233509e9f --- /dev/null +++ b/src/Form/PostType.php @@ -0,0 +1,31 @@ +add('title') + ->add('summary') + ->add('body') + ->add('status') + ->add('createdAt') + ->add('updatedAt') + ->add('postImage') + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => Post::class, + ]); + } +} diff --git a/symfony.lock b/symfony.lock index c0c232b48f2b69de6fd4e42691e40103206537ac..449e7c223e8c500cad4051e91bbb3e3cb54bafb8 100644 --- a/symfony.lock +++ b/symfony.lock @@ -228,6 +228,18 @@ "sebastian/version": { "version": "3.0.2" }, + "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.3.2" }, @@ -532,6 +544,19 @@ "symfony/uid": { "version": "v5.3.2" }, + "symfony/validator": { + "version": "4.3", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "4.3", + "ref": "d902da3e4952f18d3bf05aab29512eb61cabd869" + }, + "files": [ + "config/packages/test/validator.yaml", + "config/packages/validator.yaml" + ] + }, "symfony/var-dumper": { "version": "v5.3.2" }, diff --git a/templates/post/index.html.twig b/templates/post/index.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..ae11c3c273d5267aebcf0cf40d78fefa0f2528d4 --- /dev/null +++ b/templates/post/index.html.twig @@ -0,0 +1,47 @@ +{% extends 'base.html.twig' %} + +{% block title %}Post index{% endblock %} + +{% block body %} +

Post index

+ + + + + + + + + + + + + + + + + {% for post in posts %} + + + + + + + + + + + + {% else %} + + + + {% endfor %} + +
IdTitleSummaryBodyStatusCreatedAtUpdatedAtPostImageactions
{{ post.id }}{{ post.title }}{{ post.summary }}{{ post.body }}{{ post.status }}{{ post.createdAt ? post.createdAt|date('Y-m-d H:i:s') : '' }}{{ post.updatedAt ? post.updatedAt|date('Y-m-d H:i:s') : '' }}{{ post.postImage }} + show + edit +
no records found
+ + Create new +{% endblock %} diff --git a/templates/post/show.html.twig b/templates/post/show.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..556706f9159cb4a2a7541597de594a96d66a91c6 --- /dev/null +++ b/templates/post/show.html.twig @@ -0,0 +1,50 @@ +{% extends 'base.html.twig' %} + +{% block title %}Post{% endblock %} + +{% block body %} +

Post

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id{{ post.id }}
Title{{ post.title }}
Summary{{ post.summary }}
Body{{ post.body }}
Status{{ post.status }}
CreatedAt{{ post.createdAt ? post.createdAt|date('Y-m-d H:i:s') : '' }}
UpdatedAt{{ post.updatedAt ? post.updatedAt|date('Y-m-d H:i:s') : '' }}
PostImage{{ post.postImage }}
+ + back to list + + edit + + {{ include('post/_delete_form.html.twig') }} +{% endblock %}