vendor/nellapp/sdk-bundle/src/ActivityFeed/Entity/AbstractActivityFeed.php line 12

Open in your IDE?
  1. <?php
  2. namespace Nellapp\Bundle\SDKBundle\ActivityFeed\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelInterface;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Doctrine\Common\Collections\Collection;
  7. use Symfony\Component\Serializer\Annotation as Serial;
  8. #[ORM\MappedSuperclass]
  9. abstract class AbstractActivityFeed implements ActivityFeedInterface
  10. {
  11. #[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
  12. protected ?int $id = null;
  13. #[ORM\OneToMany(mappedBy: 'activityFeed', targetEntity: ActivityInterface::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
  14. protected Collection $activities;
  15. #[ORM\ManyToOne(targetEntity: ChannelInterface::class, fetch: 'EAGER')]
  16. #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  17. protected ?ChannelInterface $channel = null;
  18. public function __construct()
  19. {
  20. $this->activities = new ArrayCollection();
  21. }
  22. public static function getPermissionResourceClass(): ?string
  23. {
  24. return null;
  25. }
  26. public function getOwnerChannel(): ?ChannelInterface
  27. {
  28. return $this->getChannel();
  29. }
  30. public function __toString(): string
  31. {
  32. return '';
  33. }
  34. #[Serial\Groups(['GlobalJSVariable'])]
  35. public function getId(): ?int
  36. {
  37. return $this->id;
  38. }
  39. public function getActivities(): Collection
  40. {
  41. return $this->activities;
  42. }
  43. public function addActivity(ActivityInterface $activity): static
  44. {
  45. if (!$this->getActivities()->contains($activity)) {
  46. $this->getActivities()->add($activity);
  47. }
  48. return $this;
  49. }
  50. public function removeActivity(ActivityInterface $activity): static
  51. {
  52. if ($this->getActivities()->contains($activity)) {
  53. $this->getActivities()->removeElement($activity);
  54. }
  55. return $this;
  56. }
  57. public function setActivities(Collection $activities): static
  58. {
  59. $this->activities = $activities;
  60. return $this;
  61. }
  62. public function getChannel(): ?ChannelInterface
  63. {
  64. return $this->channel;
  65. }
  66. public function setChannel(?ChannelInterface $channel): static
  67. {
  68. $this->channel = $channel;
  69. return $this;
  70. }
  71. }