<?php
namespace App\Entity\CustomizableView;
use App\Entity\Account\User;
use App\Entity\Channel\Channel;
use App\Repository\CustomizableView\CustomViewChannelRepository;
use App\Validator\Constraints\CustomViewChannelCountUserConstraint;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Entity;
use Nellapp\Bundle\SDKBundle\Entity\AbstractCustomView;
use Nellapp\Bundle\SDKBundle\Permission\UserOwner\UserOwnerResourceInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
#[Entity(repositoryClass: CustomViewChannelRepository::class)]
#[ORM\Table('custom_view_channel')]
#[
UniqueEntity(
fields: ['channel', 'user', 'name', 'type'],
message: 'You must set a unique name for your views'
),
CustomViewChannelCountUserConstraint(
message: ''
)
]
class CustomViewChannel extends AbstractCustomView implements UserOwnerResourceInterface
{
const CURSUS_VIEW = 'cursus_view';
const COMPANY_VIEW = 'company_view';
const CONTACT_VIEW = 'contact_view';
const ADMIN = 'admin';
const FORMER = 'former';
const PURCHASE_ORDER_VIEW = 'purchase_order_view';
#[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private ?User $user = null;
#[ORM\ManyToOne(targetEntity: Channel::class)]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private ?Channel $channel = null;
#[ORM\Column(type: 'string', nullable: false)]
private ?string $type = null;
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): CustomViewChannel
{
$this->user = $user;
return $this;
}
public function getChannel(): ?Channel
{
return $this->channel;
}
public function setChannel(?Channel $channel): CustomViewChannel
{
$this->channel = $channel;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): CustomViewChannel
{
$this->type = $type;
return $this;
}
public function getUserOwners(): array
{
return [
$this->getUser(),
];
}
}