- trop de trucs d'un coup... je vais faire attention ensuite ^^'

This commit is contained in:
Jérémy Guillot
2024-06-10 13:57:50 +02:00
parent 9595831aa3
commit c46e1a0a5c
69 changed files with 4004 additions and 385 deletions

View File

@@ -28,6 +28,15 @@ class Chapter
#[ORM\OneToMany(mappedBy: 'chapter', targetEntity: Page::class, orphanRemoval: true)]
private Collection $pagesLink;
#[ORM\Column(nullable: true)]
private ?int $volume = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $title = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $localPath = null;
public function __construct()
{
$this->pagesLink = new ArrayCollection();
@@ -105,16 +114,52 @@ class Chapter
}
public function getPageByNumber(int $number): ?Page
{
/**
* @var Page $page
*/
foreach ($this->pagesLink as $page) {
if ($page->getNumber() === $number) {
return $page;
}
}
{
/**
* @var Page $page
*/
foreach ($this->pagesLink as $page) {
if ($page->getNumber() === $number) {
return $page;
}
}
return null;
}
return null;
}
public function getVolume(): ?int
{
return $this->volume;
}
public function setVolume(?int $volume): static
{
$this->volume = $volume;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): static
{
$this->title = $title;
return $this;
}
public function getLocalPath(): ?string
{
return $this->localPath;
}
public function setLocalPath(?string $localPath): static
{
$this->localPath = $localPath;
return $this;
}
}

View File

@@ -0,0 +1,100 @@
<?php
namespace App\Entity;
use App\Repository\ContentSourceRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ContentSourceRepository::class)]
class ContentSource
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $baseUrl = null;
#[ORM\Column(length: 255)]
private ?string $imageSelector = null;
#[ORM\Column(length: 255)]
private ?string $NextPageSelector = null;
#[ORM\Column(length: 255)]
private ?string $chapterUrlFormat = null;
#[ORM\Column(length: 255)]
private ?string $scrapingType = null;
public function getId(): ?int
{
return $this->id;
}
public function getBaseUrl(): ?string
{
return $this->baseUrl;
}
public function setBaseUrl(string $baseUrl): static
{
$this->baseUrl = $baseUrl;
return $this;
}
public function getImageSelector(): ?string
{
return $this->imageSelector;
}
public function setImageSelector(string $imageSelector): static
{
$this->imageSelector = $imageSelector;
return $this;
}
public function getNextPageSelector(): ?string
{
return $this->NextPageSelector;
}
public function setNextPageSelector(string $NextPageSelector): static
{
$this->NextPageSelector = $NextPageSelector;
return $this;
}
public function getChapterUrlFormat(): ?string
{
return $this->chapterUrlFormat;
}
public function setChapterUrlFormat(string $chapterUrlFormat): static
{
$this->chapterUrlFormat = $chapterUrlFormat;
return $this;
}
public function getChapterUrl(string $mangaTitle, float $chapterNumber): string
{
return sprintf($this->chapterUrlFormat, $mangaTitle, $chapterNumber);
}
public function getScrapingType(): ?string
{
return $this->scrapingType;
}
public function setScrapingType(string $scrapingType): static
{
$this->scrapingType = $scrapingType;
return $this;
}
}

View File

@@ -22,7 +22,7 @@ class Manga
#[ORM\OneToMany(mappedBy: 'manga', targetEntity: Chapter::class, orphanRemoval: true)]
private Collection $chapters;
#[ORM\Column(length: 255)]
#[ORM\Column(length: 255, unique: true)]
private ?string $slug = null;
#[ORM\Column(length: 255, nullable: true)]
@@ -37,9 +37,25 @@ class Manga
#[ORM\Column(type: Types::ARRAY, nullable: true)]
private ?array $genres = null;
#[ORM\Column]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(nullable: true)]
private ?float $rating = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $author = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $externalId = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $status = null;
public function __construct()
{
$this->chapters = new ArrayCollection();
$this->createdAt = new \DateTimeImmutable();
}
public function getId(): ?int
@@ -67,15 +83,15 @@ class Manga
return $this->chapters;
}
public function getChapterByNumber(float $number): ?Chapter
{
foreach ($this->chapters as $chapter) {
if ($chapter->getNumber() === $number) {
return $chapter;
}
}
return null;
}
public function getChapterByNumber(float $number): ?Chapter
{
foreach ($this->chapters as $chapter) {
if ($chapter->getNumber() === $number) {
return $chapter;
}
}
return null;
}
public function addChapter(Chapter $chapter): self
{
@@ -158,4 +174,64 @@ class Manga
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
public function getRating(): ?float
{
return $this->rating;
}
public function setRating(?float $rating): static
{
$this->rating = $rating;
return $this;
}
public function getAuthor(): ?string
{
return $this->author;
}
public function setAuthor(?string $author): static
{
$this->author = $author;
return $this;
}
public function getExternalId(): ?string
{
return $this->externalId;
}
public function setExternalId(?string $externalId): static
{
$this->externalId = $externalId;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): static
{
$this->status = $status;
return $this;
}
}