src/Entity/Channel/Place.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Channel;
  3. use App\Entity\Sync\SyncableInterface;
  4. use App\Repository\Channel\PlaceRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Drosalys\Bundle\ApiBundle\Serializer\Attributes\IdGroups;
  9. use Nellapp\Bundle\SDKBundle\Channel\Entity\Place\PlaceInterface;
  10. use Nellapp\Bundle\SDKBundle\Channel\Entity\Place\PlaceMethodTrait;
  11. use Nellapp\Bundle\SDKBundle\Sync\EntityKeys;
  12. use Symfony\Component\Serializer\Annotation as Serial;
  13. use Symfony\Component\Validator\Constraints as Assert;
  14. #[
  15.     ORM\Entity(repositoryClass: PlaceRepository::class),
  16.     ORM\Index(columns: ['label'], flags: ['fulltext']),
  17.     ORM\Table(name: 'channel_places')
  18. ]
  19. class Place implements PlaceInterface, SyncableInterface
  20. {
  21.     use PlaceMethodTrait;
  22.     #[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
  23.     #[Serial\Groups(['Sync', 'Manager'])]
  24.     private ?int $id = null;
  25.     #[ORM\Column(type: 'string', length: 255)]
  26.     #[
  27.         Assert\NotBlank(message: 'place.label.NotBlank'),
  28.         Assert\Length(
  29.             min: 2,
  30.             max: 255,
  31.             minMessage: 'place.length.min',
  32.             maxMessage: 'place.length.max'
  33.         )
  34.     ]
  35.     #[Serial\Groups(['Manager', 'Sync'])]
  36.     private ?string $label = null;
  37.     #[ORM\OneToMany(mappedBy: 'place', targetEntity: Room::class, cascade: ['persist', 'remove'])]
  38.     #[IdGroups(['Sync'])]
  39.     private ?Collection $rooms;
  40.     #[ORM\ManyToOne(targetEntity: Channel::class)]
  41.     #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  42.     #[IdGroups(['Sync'])]
  43.     private ?Channel $channel = null;
  44.     public function __construct()
  45.     {
  46.         $this->rooms = new ArrayCollection();
  47.     }
  48.     public static function getSyncKey(): string
  49.     {
  50.         return EntityKeys::CHANNEL_PLACE;
  51.     }
  52.     public function getSyncDisplayLabel(): string
  53.     {
  54.         return $this->getLabel() ?? '';
  55.     }
  56. }