feat(mail) : MailFolder entity + repository

This commit is contained in:
2026-05-19 23:16:17 +02:00
parent 3cac87aa24
commit 0c80159d7e
2 changed files with 149 additions and 0 deletions

115
src/Entity/MailFolder.php Normal file
View File

@@ -0,0 +1,115 @@
<?php
declare(strict_types=1);
namespace App\Entity;
use App\Repository\MailFolderRepository;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: MailFolderRepository::class)]
#[ORM\Table(name: 'mail_folder')]
#[ORM\Index(columns: ['parent_path'], name: 'idx_mail_folder_parent_path')]
class MailFolder
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 500, unique: true)]
private string $path;
#[ORM\Column(length: 255)]
private string $displayName;
#[ORM\Column(length: 500, nullable: true)]
private ?string $parentPath = null;
#[ORM\Column]
private int $unreadCount = 0;
#[ORM\Column]
private int $totalCount = 0;
#[ORM\Column(type: 'datetimetz_immutable', nullable: true)]
private ?DateTimeImmutable $lastSyncedAt = null;
public function getId(): ?int
{
return $this->id;
}
public function getPath(): string
{
return $this->path;
}
public function setPath(string $path): static
{
$this->path = $path;
return $this;
}
public function getDisplayName(): string
{
return $this->displayName;
}
public function setDisplayName(string $displayName): static
{
$this->displayName = $displayName;
return $this;
}
public function getParentPath(): ?string
{
return $this->parentPath;
}
public function setParentPath(?string $parentPath): static
{
$this->parentPath = $parentPath;
return $this;
}
public function getUnreadCount(): int
{
return $this->unreadCount;
}
public function setUnreadCount(int $unreadCount): static
{
$this->unreadCount = $unreadCount;
return $this;
}
public function getTotalCount(): int
{
return $this->totalCount;
}
public function setTotalCount(int $totalCount): static
{
$this->totalCount = $totalCount;
return $this;
}
public function getLastSyncedAt(): ?DateTimeImmutable
{
return $this->lastSyncedAt;
}
public function setLastSyncedAt(?DateTimeImmutable $lastSyncedAt): static
{
$this->lastSyncedAt = $lastSyncedAt;
return $this;
}
}

View File

@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace App\Repository;
use App\Entity\MailFolder;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
class MailFolderRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, MailFolder::class);
}
/**
* @return list<MailFolder>
*/
public function findAllOrderedByPath(): array
{
return $this->createQueryBuilder('f')
->orderBy('f.path', 'ASC')
->getQuery()
->getResult()
;
}
public function findByPath(string $path): ?MailFolder
{
return $this->findOneBy(['path' => $path]);
}
}