<?php
namespace Nellapp\Bundle\SDKBundle\ActivityFeed\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use DrosalysWeb\ObjectExtensions\Blame\Model\CreatedBlameTrait;
use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampTrait;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serial;
use Nellapp\Bundle\SDKBundle\ActivityFeed\Entity\CommentActivity\CommentActivityInterface;
use Nellapp\Bundle\SDKBundle\Auth\Entity\UserInterface;
#[ORM\MappedSuperclass]
abstract class AbstractActivity implements ActivityInterface
{
use TimestampTrait;
use CreatedBlameTrait;
#[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
#[Serial\Groups(['activity:get', 'activity:delete'])]
protected ?int $id = null;
#[ORM\ManyToOne(targetEntity: ActivityFeedInterface::class, cascade: ['persist'], inversedBy: 'activities')]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
protected ?ActivityFeedInterface $activityFeed = null;
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: CommentActivityInterface::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
#[Serial\Groups(['activity:get'])]
protected Collection $comments;
public function __construct() {
$this->comments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
#[Serial\Groups(['activity:get'])]
public function getCreatedAt(): \DateTime
{
return $this->createdAt ? : $this->createdAt = new \DateTime();
}
#[Serial\Groups(['activity:get'])]
public function getCreatedBy(): ?UserInterface
{
return $this->createdBy;
}
public function getActivityFeed(): ?ActivityFeedInterface
{
return $this->activityFeed;
}
public function setActivityFeed(?ActivityFeedInterface $activityFeed): static
{
$this->activityFeed = $activityFeed;
return $this;
}
public function getComments(): Collection
{
return $this->comments;
}
public function setComments(Collection $comments): static
{
$this->comments = $comments;
return $this;
}
}