src/Entity/CustomizableView/CustomViewSuperAdmin.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity\CustomizableView;
  3. use App\Entity\Account\User;
  4. use App\Repository\CustomizableView\CustomViewSuperAdminRepository;
  5. use Doctrine\ORM\Mapping\Entity;
  6. use Nellapp\Bundle\SDKBundle\Entity\AbstractCustomView;
  7. use Nellapp\Bundle\SDKBundle\Permission\UserOwner\UserOwnerResourceInterface;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Doctrine\ORM\Mapping as ORM;
  10. #[Entity(repositoryClass: CustomViewSuperAdminRepository::class)]
  11. #[ORM\Table('custom_view_super_admin')]
  12. #[
  13.     UniqueEntity(
  14.         fields: ['user', 'name', 'type'],
  15.         message: 'You must set a unique name for your views'
  16.     ),
  17. ]
  18. class CustomViewSuperAdmin extends AbstractCustomView implements UserOwnerResourceInterface
  19. {
  20.     const USERS = 'users';
  21.     #[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
  22.     private ?int $id = null;
  23.     #[ORM\ManyToOne(targetEntity: User::class)]
  24.     #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  25.     private ?User $user = null;
  26.     #[ORM\Column(type: 'string', nullable: false)]
  27.     private ?string $type = null;
  28.     function getId(): ?int
  29.     {
  30.         return $this->id;
  31.     }
  32.     public function getUser(): ?User
  33.     {
  34.         return $this->user;
  35.     }
  36.     public function setUser(?User $user): static
  37.     {
  38.         $this->user = $user;
  39.         return $this;
  40.     }
  41.     public function getType(): ?string
  42.     {
  43.         return $this->type;
  44.     }
  45.     public function setType(?string $type): static
  46.     {
  47.         $this->type = $type;
  48.         return $this;
  49.     }
  50.     public function getUserOwners(): array
  51.     {
  52.         return [
  53.             $this->getUser(),
  54.         ];
  55.     }
  56. }