src/Entity/Channel/Service.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Channel;
  3. use App\Entity\Account\User;
  4. use App\Repository\Channel\ServiceRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampInterface;
  9. use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampTrait;
  10. use Nellapp\Bundle\SDKBundle\Auth\Entity\UserInterface;
  11. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelInterface;
  12. use Nellapp\Bundle\SDKBundle\Channel\Entity\Service\ServiceInterface;
  13. use Nellapp\Bundle\SDKBundle\Channel\Entity\Service\ServiceMethodTrait;
  14. use Nellapp\Bundle\SDKBundle\Permission\UsersResource\UsersResourceInterface;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. use Symfony\Component\Serializer\Annotation as Serial;
  17. #[ORM\Entity(repositoryClassServiceRepository::class)]
  18. #[ORM\Table(name'channel_services')]
  19. class Service implements TimestampInterfaceServiceInterfaceUsersResourceInterface
  20. {
  21.     use TimestampTrait;
  22.     use ServiceMethodTrait;
  23.     #[ORM\Id]
  24.     #[ORM\Column(type'integer')]
  25.     #[Serial\Groups(groups: ['Service''Conversation''Api'])]
  26.     private ?int $id null;
  27.     #[ORM\Column(type'string'length255)]
  28.     #[
  29.         Assert\NotBlank(message'entity.channel.service.name.NotBlank'),
  30.         Assert\Length(
  31.             min2,
  32.             max255,
  33.             minMessage'entity.channel.service.name.min',
  34.             maxMessage'entity.channel.service.name.max',
  35.         )
  36.     ]
  37.     #[Serial\Groups(groups: ['Service''Conversation''Api'])]
  38.     private ?string $label null;
  39.     #[
  40.         ORM\ManyToMany(targetEntityUser::class, inversedBy'services'),
  41.         ORM\JoinTable('channel_service_users')
  42.     ]
  43.     private Collection $users;
  44.     #[
  45.         ORM\ManyToOne(targetEntityChannelInterface::class),
  46.         ORM\JoinColumn(nullablefalse),
  47.     ]
  48.     private ?ChannelInterface $channel null;
  49.     #[ORM\Column(type'boolean'nullablefalse)]
  50.     private ?bool $enableOnNim null;
  51.     public function __construct()
  52.     {
  53.         $this->users = new ArrayCollection();
  54.     }
  55.     public function hasUser(?UserInterface $user, array $tags = []): bool
  56.     {
  57.         if ($user === null) {
  58.             return false;
  59.         }
  60.         return $this->getUsers()->contains($user);
  61.     }
  62. }