feat(bookstack) : add TaskBookStackLink entity and repository
This commit is contained in:
113
src/Entity/TaskBookStackLink.php
Normal file
113
src/Entity/TaskBookStackLink.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\TaskBookStackLinkRepository;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: TaskBookStackLinkRepository::class)]
|
||||
#[ORM\UniqueConstraint(name: 'UNIQ_task_bookstack_link', columns: ['task_id', 'bookstack_id', 'bookstack_type'])]
|
||||
class TaskBookStackLink
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Task::class)]
|
||||
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
|
||||
private Task $task;
|
||||
|
||||
#[ORM\Column]
|
||||
private int $bookstackId;
|
||||
|
||||
#[ORM\Column(length: 10)]
|
||||
private string $bookstackType;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private string $title;
|
||||
|
||||
#[ORM\Column(length: 500)]
|
||||
private string $url;
|
||||
|
||||
#[ORM\Column]
|
||||
private DateTimeImmutable $createdAt;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->createdAt = new DateTimeImmutable();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getTask(): Task
|
||||
{
|
||||
return $this->task;
|
||||
}
|
||||
|
||||
public function setTask(Task $task): static
|
||||
{
|
||||
$this->task = $task;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBookstackId(): int
|
||||
{
|
||||
return $this->bookstackId;
|
||||
}
|
||||
|
||||
public function setBookstackId(int $bookstackId): static
|
||||
{
|
||||
$this->bookstackId = $bookstackId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBookstackType(): string
|
||||
{
|
||||
return $this->bookstackType;
|
||||
}
|
||||
|
||||
public function setBookstackType(string $bookstackType): static
|
||||
{
|
||||
$this->bookstackType = $bookstackType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle(string $title): static
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUrl(): string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function setUrl(string $url): static
|
||||
{
|
||||
$this->url = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
}
|
||||
23
src/Repository/TaskBookStackLinkRepository.php
Normal file
23
src/Repository/TaskBookStackLinkRepository.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\TaskBookStackLink;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
class TaskBookStackLinkRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, TaskBookStackLink::class);
|
||||
}
|
||||
|
||||
/** @return TaskBookStackLink[] */
|
||||
public function findByTaskId(int $taskId): array
|
||||
{
|
||||
return $this->findBy(['task' => $taskId], ['createdAt' => 'DESC']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user