added validator
This commit is contained in:
parent
cc470de716
commit
c39ac0d299
|
@ -20,6 +20,7 @@
|
||||||
"symfony/proxy-manager-bridge": "5.2.*",
|
"symfony/proxy-manager-bridge": "5.2.*",
|
||||||
"symfony/security-bundle": "5.2.*",
|
"symfony/security-bundle": "5.2.*",
|
||||||
"symfony/twig-bundle": "^5.2",
|
"symfony/twig-bundle": "^5.2",
|
||||||
|
"symfony/validator": "5.2.*",
|
||||||
"symfony/yaml": "5.2.*",
|
"symfony/yaml": "5.2.*",
|
||||||
"twig/extra-bundle": "^2.12|^3.0",
|
"twig/extra-bundle": "^2.12|^3.0",
|
||||||
"twig/twig": "^2.12|^3.0"
|
"twig/twig": "^2.12|^3.0"
|
||||||
|
|
|
@ -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": "0474966a06e7b2b0454614e9b684fd7b",
|
"content-hash": "47f05c4f8f1d3ea9fca636127ecfd3d8",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "composer/package-versions-deprecated",
|
"name": "composer/package-versions-deprecated",
|
||||||
|
@ -5893,6 +5893,115 @@
|
||||||
],
|
],
|
||||||
"time": "2021-03-21T16:15:38+00:00"
|
"time": "2021-03-21T16:15:38+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/validator",
|
||||||
|
"version": "v5.2.9",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/validator.git",
|
||||||
|
"reference": "3c16d6c2036190f9033643057168a6d8c5617886"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/validator/zipball/3c16d6c2036190f9033643057168a6d8c5617886",
|
||||||
|
"reference": "3c16d6c2036190f9033643057168a6d8c5617886",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"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/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": "^4.4|^5.0",
|
||||||
|
"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.2.9"
|
||||||
|
},
|
||||||
|
"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-05-17T20:21:27+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/var-dumper",
|
"name": "symfony/var-dumper",
|
||||||
"version": "v5.2.8",
|
"version": "v5.2.8",
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
framework:
|
||||||
|
validation:
|
||||||
|
not_compromised_password: false
|
|
@ -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\: []
|
|
@ -2,17 +2,38 @@
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Entity\Blog;
|
||||||
|
use App\Repository\BlogRepository;
|
||||||
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class BlogController
|
||||||
|
* @package App\Controller
|
||||||
|
*/
|
||||||
class BlogController extends AbstractController
|
class BlogController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/', name: 'blog')]
|
#[Route('/', name: 'blogs')]
|
||||||
public function index(): Response
|
public function index(BlogRepository $blogRepository): Response
|
||||||
{
|
{
|
||||||
return $this->render('blog/index.html.twig', [
|
return $this->render('blog/index.html.twig', [
|
||||||
'controller_name' => 'BlogController',
|
'blogs' => $blogRepository->findAll()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @param \App\Repository\BlogRepository $blogRepository
|
||||||
|
*
|
||||||
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
|
*/
|
||||||
|
#[Route('/blog/{id}', name: 'blog')]
|
||||||
|
public function show($id, BlogRepository $blogRepository): Response
|
||||||
|
{
|
||||||
|
return $this->render('blog/show.html.twig', [
|
||||||
|
'blog' => $blogRepository->findOneBy(['id' => $id])
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,8 +147,8 @@ class AppAuthenticator extends AbstractFormLoginAuthenticator implements Passwor
|
||||||
*/
|
*/
|
||||||
public function checkCredentials($credentials, UserInterface $user)
|
public function checkCredentials($credentials, UserInterface $user)
|
||||||
{
|
{
|
||||||
return true;
|
//return true;
|
||||||
//return $this->passwordEncoder->isPasswordValid($user, $credentials['password']);
|
return $this->passwordEncoder->isPasswordValid($user, $credentials['password']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -165,7 +165,7 @@ class AppAuthenticator extends AbstractFormLoginAuthenticator implements Passwor
|
||||||
return new RedirectResponse($targetPath);
|
return new RedirectResponse($targetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RedirectResponse($this->urlGenerator->generate('blog'));
|
return new RedirectResponse($this->urlGenerator->generate('blogs'));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getLoginUrl()
|
protected function getLoginUrl()
|
||||||
|
|
13
symfony.lock
13
symfony.lock
|
@ -350,6 +350,19 @@
|
||||||
"symfony/uid": {
|
"symfony/uid": {
|
||||||
"version": "v5.2.6"
|
"version": "v5.2.6"
|
||||||
},
|
},
|
||||||
|
"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": {
|
"symfony/var-dumper": {
|
||||||
"version": "v5.2.8"
|
"version": "v5.2.8"
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,18 +3,10 @@
|
||||||
{% block title %}Hello BlogController!{% endblock %}
|
{% block title %}Hello BlogController!{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<style>
|
{% for blog in blogs %}
|
||||||
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
|
<h4>{{ blog }}</h4>
|
||||||
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
|
<p>{{ blog.teaser }}</p>
|
||||||
</style>
|
|
||||||
|
|
||||||
<div class="example-wrapper">
|
<a href="{{ path('blog', { id: blog.id }) }}">View more …</a>
|
||||||
<h1>Hello {{ controller_name }}! ✅</h1>
|
{% endfor %}
|
||||||
|
|
||||||
This friendly message is coming from:
|
|
||||||
<ul>
|
|
||||||
<li>Your controller at <code><a href="{{ '/Users/tracer/Projects/24unix.net/24unix.net_web/24unix/src/Controller/BlogController.php'|file_link(0) }}">src/Controller/BlogController.php</a></code></li>
|
|
||||||
<li>Your template at <code><a href="{{ '/Users/tracer/Projects/24unix.net/24unix.net_web/24unix/templates/blog/index.html.twig'|file_link(0) }}">templates/blog/index.html.twig</a></code></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
Blogtest
|
||||||
|
{{ blog.content }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue