src/Entity/CustomizableView/CustomViewChannel.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity\CustomizableView;
  3. use App\Entity\Account\User;
  4. use App\Entity\Channel\Channel;
  5. use App\Repository\CustomizableView\CustomViewChannelRepository;
  6. use App\Validator\Constraints\CustomViewChannelCountUserConstraint;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Doctrine\ORM\Mapping\Entity;
  9. use Nellapp\Bundle\SDKBundle\Entity\AbstractCustomView;
  10. use Nellapp\Bundle\SDKBundle\Permission\UserOwner\UserOwnerResourceInterface;
  11. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  12. #[Entity(repositoryClass: CustomViewChannelRepository::class)]
  13. #[ORM\Table('custom_view_channel')]
  14. #[
  15. UniqueEntity(
  16. fields: ['channel', 'user', 'name', 'type'],
  17. message: 'You must set a unique name for your views'
  18. ),
  19. CustomViewChannelCountUserConstraint(
  20. message: ''
  21. )
  22. ]
  23. class CustomViewChannel extends AbstractCustomView implements UserOwnerResourceInterface
  24. {
  25. const CURSUS_VIEW = 'cursus_view';
  26. const COMPANY_VIEW = 'company_view';
  27. const CONTACT_VIEW = 'contact_view';
  28. const SESSION_VIEW = 'session_view';
  29. const ADMIN = 'admin';
  30. const FORMER = 'former';
  31. const PURCHASE_ORDER_VIEW = 'purchase_order_view';
  32. #[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
  33. private ?int $id = null;
  34. #[ORM\ManyToOne(targetEntity: User::class)]
  35. #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  36. private ?User $user = null;
  37. #[ORM\ManyToOne(targetEntity: Channel::class)]
  38. #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  39. private ?Channel $channel = null;
  40. #[ORM\Column(type: 'string', nullable: false)]
  41. private ?string $type = null;
  42. public function getId(): ?int
  43. {
  44. return $this->id;
  45. }
  46. public function getUser(): ?User
  47. {
  48. return $this->user;
  49. }
  50. public function setUser(?User $user): CustomViewChannel
  51. {
  52. $this->user = $user;
  53. return $this;
  54. }
  55. public function getChannel(): ?Channel
  56. {
  57. return $this->channel;
  58. }
  59. public function setChannel(?Channel $channel): CustomViewChannel
  60. {
  61. $this->channel = $channel;
  62. return $this;
  63. }
  64. public function getType(): ?string
  65. {
  66. return $this->type;
  67. }
  68. public function setType(?string $type): CustomViewChannel
  69. {
  70. $this->type = $type;
  71. return $this;
  72. }
  73. public function getUserOwners(): array
  74. {
  75. return [
  76. $this->getUser(),
  77. ];
  78. }
  79. }