Add Symfony Validation to entity User

This commit is contained in:
2026-06-25 16:08:56 +02:00
parent dbf23badf9
commit c21b869641
5 changed files with 32 additions and 4 deletions
+3 -3
View File
@@ -34,10 +34,10 @@ MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
###> LISTMONK/API ###
LISTMONK_BASE_URL=https://listmonk.powerpme.com
LISTMONK_API_USER=
LISTMONK_TOKEN=
LISTMONK_API_USER=MaherAPI
LISTMONK_TOKEN=BVqvuHgU3N1qstEiLeWM9Ocv9b5jSYaS
###> LISTMONK/API ###
###> monolog/mattermost ###
MATTERMOST_WEBHOOK_URL=https://mattermost.powerpme.com/hooks/
MATTERMOST_WEBHOOK_URL=https://mattermost.powerpme.com/hooks/anc9zweugj8fprj1zifdxy6m7e
###< monolog/mattermost ###
Binary file not shown.
Binary file not shown.
+24
View File
@@ -12,6 +12,8 @@ use Symfony\Component\Routing\Attribute\Route;
use Psr\Log\LoggerInterface;
use Symfony\Component\Process\Process;
#[Route('/admin/test')]
final class TestController extends AbstractController
{
@@ -63,4 +65,26 @@ final class TestController extends AbstractController
return $this->render('/frontend/test.html.twig', []);
}
#[Route('/url', name: 'app_test_url')]
public function url()
{
$process = new Process([
'yt-dlp',
'--print',
'%(title)s|%(filesize,filesize_approx)s',
'--', // 🛡️ Protection cruciale contre l'injection d'arguments
'https://www.youtube.com/watch?v=Z8hhP38-4Eg'
]);
$process->run();
//dd($process->getOutput());
if (!$process->isSuccessful()) {
echo $process->getCommandLine() . "<br>" . $process->getErrorOutput();
die;
return new Response("error1", Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
//
}
+5 -1
View File
@@ -9,9 +9,12 @@ use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\Table(name: '`user`')]
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email.')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
@@ -20,6 +23,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
private ?int $id = null;
#[ORM\Column(length: 180, unique: true)]
#[Assert\Email]
private ?string $email = null;
#[ORM\Column]