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(repositoryClassCustomViewChannelRepository::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 ADMIN 'admin';
  29.     const FORMER 'former';
  30.     const PURCHASE_ORDER_VIEW 'purchase_order_view';
  31.     #[ORM\IdORM\GeneratedValueORM\Column(type'integer')]
  32.     private ?int $id null;
  33.     #[ORM\ManyToOne(targetEntityUser::class)]
  34.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  35.     private ?User $user null;
  36.     #[ORM\ManyToOne(targetEntityChannel::class)]
  37.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  38.     private ?Channel $channel null;
  39.     #[ORM\Column(type'string'nullablefalse)]
  40.     private ?string $type null;
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getUser(): ?User
  46.     {
  47.         return $this->user;
  48.     }
  49.     public function setUser(?User $user): CustomViewChannel
  50.     {
  51.         $this->user $user;
  52.         return $this;
  53.     }
  54.     public function getChannel(): ?Channel
  55.     {
  56.         return $this->channel;
  57.     }
  58.     public function setChannel(?Channel $channel): CustomViewChannel
  59.     {
  60.         $this->channel $channel;
  61.         return $this;
  62.     }
  63.     public function getType(): ?string
  64.     {
  65.         return $this->type;
  66.     }
  67.     public function setType(?string $type): CustomViewChannel
  68.     {
  69.         $this->type $type;
  70.         return $this;
  71.     }
  72.     public function getUserOwners(): array
  73.     {
  74.         return [
  75.             $this->getUser(),
  76.         ];
  77.     }
  78. }