✨ feat(newsletter): Affiche listes de contacts et templates avec liens d'ajout et correction orthographe.
This commit is contained in:
33
migrations/Version20250801121625.php
Normal file
33
migrations/Version20250801121625.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20250801121625 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE TABLE template (id SERIAL NOT NULL, name VARCHAR(255) NOT NULL, content TEXT NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('COMMENT ON COLUMN template.content IS \'(DC2Type:array)\'');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE SCHEMA public');
|
||||
$this->addSql('DROP TABLE template');
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,7 @@ class ContactController extends AbstractController
|
||||
#[Route(path: '/artemis/newsletter/contact',name: 'artemis_newsletter_contact',methods: ['GET', 'POST'])]
|
||||
public function contacts(ContactRepository $contactRepository): Response
|
||||
{
|
||||
$r = new Contact();
|
||||
$r->setUuid(Uuid::v4());
|
||||
$r->setName("list 1");
|
||||
// Récupération des contacts triés par id (ordre croissant)
|
||||
|
||||
$contacts = $contactRepository->findBy([],['id'=>'ASC']);
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Controller\Artemis\Newsletter;
|
||||
|
||||
use App\Repository\Newsletter\TemplateRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
@@ -9,8 +10,28 @@ use Symfony\Component\Routing\Attribute\Route;
|
||||
class TemplateController extends AbstractController
|
||||
{
|
||||
#[Route(path: '/artemis/newsletter/template',name: 'artemis_newsletter_template',methods: ['GET', 'POST'])]
|
||||
public function artemis(): Response
|
||||
public function templates(TemplateRepository $templateRepository): Response
|
||||
{
|
||||
$templates = $templateRepository->findBy([],['id'=>'ASC']);
|
||||
|
||||
|
||||
// Affiche dans un template Twig (à créer)
|
||||
return $this->render('artemis/newsletter/template.twig', [
|
||||
'templates' => $templates,
|
||||
]);
|
||||
|
||||
//load template listing
|
||||
//create editor for created template
|
||||
//header
|
||||
//content modify only campain
|
||||
//footer
|
||||
|
||||
//header sortable js
|
||||
//footer sortabke js
|
||||
|
||||
//1 col 2 col 3col
|
||||
//texte image network
|
||||
//button link
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
51
src/Entity/Newsletter/Template.php
Normal file
51
src/Entity/Newsletter/Template.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Newsletter;
|
||||
|
||||
use App\Repository\Newsletter\TemplateRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: TemplateRepository::class)]
|
||||
class Template
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\Column(type: Types::ARRAY)]
|
||||
private array $content = [];
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContent(): array
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setContent(array $content): static
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
43
src/Repository/Newsletter/TemplateRepository.php
Normal file
43
src/Repository/Newsletter/TemplateRepository.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository\Newsletter;
|
||||
|
||||
use App\Entity\Newsletter\Template;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Template>
|
||||
*/
|
||||
class TemplateRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Template::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Template[] Returns an array of Template objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('t')
|
||||
// ->andWhere('t.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('t.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Template
|
||||
// {
|
||||
// return $this->createQueryBuilder('t')
|
||||
// ->andWhere('t.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h2 class="text-3xl font-semibold text-gray-800 dark:text-gray-200">istes de contacts</h2>
|
||||
<h2 class="text-3xl font-semibold text-gray-800 dark:text-gray-200">Listes de contacts</h2>
|
||||
<div>
|
||||
<a href="{{ path('artemis_newsletter_contact_add') }}" class="px-4 py-2 bg-blue-600 text-white font-medium rounded-md shadow-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900">
|
||||
+ Crée une liste de contact
|
||||
|
||||
34
templates/artemis/newsletter/template.twig
Normal file
34
templates/artemis/newsletter/template.twig
Normal file
@@ -0,0 +1,34 @@
|
||||
{% extends 'artemis/base.twig' %}
|
||||
|
||||
{% block title %}Listes de contacts{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h2 class="text-3xl font-semibold text-gray-800 dark:text-gray-200">Listes des templates</h2>
|
||||
<div>
|
||||
<a href="{{ path('artemis_newsletter_contact_add') }}" class="px-4 py-2 bg-blue-600 text-white font-medium rounded-md shadow-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900">
|
||||
+ Crée un templates
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-6">
|
||||
{% for template in templates %}
|
||||
<a href="" class="card-contact mt-6">
|
||||
<div class="card-body flex items-center">
|
||||
|
||||
<div class="px-3 py-2 rounded bg-indigo-600 text-white mr-3">
|
||||
<i class="fad fa-user"></i>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col">
|
||||
<h1 class="font-semibold">{{ template.name }}</h1>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</a>
|
||||
|
||||
{% else %}
|
||||
<div class="col-span-4 text-center text-gray-400 dark:text-gray-500 font-bold">Aucune liste trouvée.</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user