WIP: Symfony 6 project remake #2
|
@ -3,11 +3,10 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Entity\Blog;
|
namespace App\Entity\Blog;
|
||||||
|
|
||||||
use App\Entity\Blog\File;
|
|
||||||
use App\Entity\Blog\Post;
|
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Repository\Blog\CommentRepository;
|
use App\Repository\Blog\CommentRepository;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: CommentRepository::class)]
|
#[ORM\Entity(repositoryClass: CommentRepository::class)]
|
||||||
|
@ -43,20 +42,20 @@ class Comment
|
||||||
#[ORM\JoinColumn(name: 'author_id')]
|
#[ORM\JoinColumn(name: 'author_id')]
|
||||||
private User $author;
|
private User $author;
|
||||||
|
|
||||||
/** @var ArrayCollection|File[] */
|
/** @var Collection<int, File> */
|
||||||
#[ORM\ManyToMany(targetEntity: File::class, fetch: 'EXTRA_LAZY')]
|
#[ORM\ManyToMany(targetEntity: File::class, fetch: 'EXTRA_LAZY')]
|
||||||
#[ORM\JoinTable(name: 'comments_files', schema: 'posts')]
|
#[ORM\JoinTable(name: 'comments_files', schema: 'posts')]
|
||||||
#[ORM\JoinColumn(name: 'comment_id')]
|
#[ORM\JoinColumn(name: 'comment_id')]
|
||||||
#[ORM\InverseJoinColumn(name: 'file_id')]
|
#[ORM\InverseJoinColumn(name: 'file_id')]
|
||||||
private ArrayCollection $files;
|
private Collection $files;
|
||||||
|
|
||||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
|
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
|
||||||
#[ORM\JoinColumn(name: 'parent_id', nullable: true)]
|
#[ORM\JoinColumn(name: 'parent_id', nullable: true)]
|
||||||
private ?self $parent;
|
private ?self $parent;
|
||||||
|
|
||||||
/** @var ArrayCollection|self[] */
|
/** @var Collection<int, self> */
|
||||||
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class, fetch: 'EXTRA_LAZY')]
|
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class, fetch: 'EXTRA_LAZY')]
|
||||||
private ArrayCollection $children;
|
private Collection $children;
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
@ -159,10 +158,8 @@ class Comment
|
||||||
$this->files->removeElement($files);
|
$this->files->removeElement($files);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** @return Collection<int, File> */
|
||||||
* @return File[]|ArrayCollection
|
public function getFiles(): Collection
|
||||||
*/
|
|
||||||
public function getFiles(): iterable
|
|
||||||
{
|
{
|
||||||
return $this->files;
|
return $this->files;
|
||||||
}
|
}
|
||||||
|
@ -208,8 +205,8 @@ class Comment
|
||||||
$this->children->removeElement($children);
|
$this->children->removeElement($children);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return ArrayCollection|self[] */
|
/** @return Collection<int, self> */
|
||||||
public function getChildren(): iterable
|
public function getChildren(): Collection
|
||||||
{
|
{
|
||||||
return $this->children;
|
return $this->children;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace App\Entity\Blog;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Repository\Blog\TagRepository;
|
use App\Repository\Blog\TagRepository;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: TagRepository::class)]
|
#[ORM\Entity(repositoryClass: TagRepository::class)]
|
||||||
|
@ -29,6 +30,7 @@ class Post
|
||||||
#[ORM\Column(name: 'updated_at', type: 'datetime', nullable: true)]
|
#[ORM\Column(name: 'updated_at', type: 'datetime', nullable: true)]
|
||||||
private ?\DateTime $updatedAt;
|
private ?\DateTime $updatedAt;
|
||||||
|
|
||||||
|
// TODO: Native Enum
|
||||||
#[ORM\Column(name: 'type', type: 'string', length: 6)]
|
#[ORM\Column(name: 'type', type: 'string', length: 6)]
|
||||||
private string $type = self::TYPE_POST;
|
private string $type = self::TYPE_POST;
|
||||||
|
|
||||||
|
@ -42,19 +44,20 @@ class Post
|
||||||
#[ORM\JoinColumn(name: 'author')]
|
#[ORM\JoinColumn(name: 'author')]
|
||||||
private User $author;
|
private User $author;
|
||||||
|
|
||||||
/** @var ArrayCollection|File[] */
|
/** @var Collection<int, File> */
|
||||||
#[ORM\ManyToMany(targetEntity: File::class, cascade: ['persist'], fetch: 'EXTRA_LAZY')]
|
#[ORM\ManyToMany(targetEntity: File::class, cascade: ['persist'], fetch: 'EXTRA_LAZY')]
|
||||||
#[ORM\JoinTable(name: 'posts_files', schema: 'posts')]
|
#[ORM\JoinTable(name: 'posts_files', schema: 'posts')]
|
||||||
#[ORM\JoinColumn(name: 'post_id')]
|
#[ORM\JoinColumn(name: 'post_id')]
|
||||||
#[ORM\InverseJoinColumn(name: 'file_id')]
|
#[ORM\InverseJoinColumn(name: 'file_id')]
|
||||||
private $files;
|
private Collection $files;
|
||||||
|
|
||||||
|
/** @var Collection<int, PostTag> */
|
||||||
#[ORM\OneToMany(mappedBy: 'post', targetEntity: PostTag::class, cascade: ['persist'], fetch: 'EXTRA_LAZY', orphanRemoval: true)]
|
#[ORM\OneToMany(mappedBy: 'post', targetEntity: PostTag::class, cascade: ['persist'], fetch: 'EXTRA_LAZY', orphanRemoval: true)]
|
||||||
private ArrayCollection $postTags;
|
private Collection $postTags;
|
||||||
|
|
||||||
/** @var ArrayCollection|Comment[] */
|
/** @var Collection<int, Comment> */
|
||||||
#[ORM\OneToMany(targetEntity: Comment::class, mappedBy: 'post', cascade: ['persist'], )]
|
#[ORM\OneToMany(mappedBy: 'post', targetEntity: Comment::class, cascade: ['persist'])]
|
||||||
private ArrayCollection $comments;
|
private Collection $comments;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(string $id, User $author, \DateTime $createdAt, string $type)
|
public function __construct(string $id, User $author, \DateTime $createdAt, string $type)
|
||||||
|
@ -124,8 +127,8 @@ class Post
|
||||||
$this->files->removeElement($files);
|
$this->files->removeElement($files);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return File[]|ArrayCollection */
|
/** @return Collection<int, File> */
|
||||||
public function getFiles(): iterable
|
public function getFiles(): Collection
|
||||||
{
|
{
|
||||||
return $this->files;
|
return $this->files;
|
||||||
}
|
}
|
||||||
|
@ -142,8 +145,8 @@ class Post
|
||||||
$this->postTags->removeElement($tag);
|
$this->postTags->removeElement($tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return PostTag[]|ArrayCollection */
|
/** @return Collection<int, PostTag> */
|
||||||
public function getPostTags(): iterable
|
public function getPostTags(): Collection
|
||||||
{
|
{
|
||||||
return $this->postTags;
|
return $this->postTags;
|
||||||
}
|
}
|
||||||
|
@ -195,8 +198,8 @@ class Post
|
||||||
$this->comments->removeElement($comment);
|
$this->comments->removeElement($comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return Comment[]|ArrayCollection */
|
/** @return Collection<int, Comment> */
|
||||||
public function getComments(): iterable
|
public function getComments(): Collection
|
||||||
{
|
{
|
||||||
return $this->comments;
|
return $this->comments;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace App\Entity;
|
||||||
|
|
||||||
use App\Repository\UserRepository;
|
use App\Repository\UserRepository;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: UserRepository::class)]
|
#[ORM\Entity(repositoryClass: UserRepository::class)]
|
||||||
|
@ -41,14 +42,17 @@ class User
|
||||||
#[ORM\Column(name: 'whitelist_only', type: 'boolean', nullable: false, options: ['default' => false])]
|
#[ORM\Column(name: 'whitelist_only', type: 'boolean', nullable: false, options: ['default' => false])]
|
||||||
private bool $whitelistOnly = false;
|
private bool $whitelistOnly = false;
|
||||||
|
|
||||||
|
/** @var Collection<int, Subscription> */
|
||||||
#[ORM\OneToMany(mappedBy: 'author', targetEntity: Subscription::class, fetch: 'EXTRA_LAZY')]
|
#[ORM\OneToMany(mappedBy: 'author', targetEntity: Subscription::class, fetch: 'EXTRA_LAZY')]
|
||||||
private ArrayCollection $subscribers;
|
private Collection $subscribers;
|
||||||
|
|
||||||
|
/** @var Collection<int, Subscription> */
|
||||||
#[ORM\OneToMany(mappedBy: 'subscriber', targetEntity: Subscription::class, fetch: 'EXTRA_LAZY')]
|
#[ORM\OneToMany(mappedBy: 'subscriber', targetEntity: Subscription::class, fetch: 'EXTRA_LAZY')]
|
||||||
private ArrayCollection $subscriptions;
|
private Collection $subscriptions;
|
||||||
|
|
||||||
|
/** @var Collection<int, SubscriptionEvent> */
|
||||||
#[ORM\OneToMany(mappedBy: 'author', targetEntity: SubscriptionEvent::class, fetch: 'EXTRA_LAZY')]
|
#[ORM\OneToMany(mappedBy: 'author', targetEntity: SubscriptionEvent::class, fetch: 'EXTRA_LAZY')]
|
||||||
private ArrayCollection $newSubscriberEvents;
|
private Collection $newSubscriberEvents;
|
||||||
|
|
||||||
#[ORM\Column(name: 'is_removed', type: 'boolean', options: ['default' => false])]
|
#[ORM\Column(name: 'is_removed', type: 'boolean', options: ['default' => false])]
|
||||||
private bool $removed = false;
|
private bool $removed = false;
|
||||||
|
@ -110,14 +114,14 @@ class User
|
||||||
$this->subscribers->removeElement($subscribers);
|
$this->subscribers->removeElement($subscribers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return Subscription[]|ArrayCollection */
|
/** @return Collection<int, Subscription> */
|
||||||
public function getSubscribers(): ArrayCollection
|
public function getSubscribers(): Collection
|
||||||
{
|
{
|
||||||
return $this->subscribers;
|
return $this->subscribers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return Subscription[]|ArrayCollection */
|
/** @return Collection<int, Subscription> */
|
||||||
public function getSubscriptions(): ArrayCollection
|
public function getSubscriptions(): Collection
|
||||||
{
|
{
|
||||||
return $this->subscriptions;
|
return $this->subscriptions;
|
||||||
}
|
}
|
||||||
|
@ -129,8 +133,8 @@ class User
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return SubscriptionEvent[]|ArrayCollection */
|
/** @return Collection<int, SubscriptionEvent> */
|
||||||
public function getNewSubscriberEvents(): ArrayCollection
|
public function getNewSubscriberEvents(): Collection
|
||||||
{
|
{
|
||||||
return $this->newSubscriberEvents;
|
return $this->newSubscriberEvents;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue