src/Entity/Channel/ChannelConfiguration.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Channel;
  3. use App\Entity\Account\User;
  4. use App\Entity\Sync\SyncableInterface;
  5. use App\Repository\Channel\ChannelConfigurationRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Drosalys\Bundle\ApiBundle\Serializer\Attributes\IdGroups;
  10. use Nellapp\Bundle\SDKBundle\Channel\Entity\Configuration\BaseChannelConfigurationInterface;
  11. use Nellapp\Bundle\SDKBundle\Channel\Entity\Configuration\BaseChannelConfigurationMethodTrait;
  12. use Nellapp\Bundle\SDKBundle\Channel\Entity\Configuration\ELearningChannelConfigurationInterface;
  13. use Nellapp\Bundle\SDKBundle\Channel\Entity\Configuration\ELearningChannelConfigurationMethodTrait;
  14. use Nellapp\Bundle\SDKBundle\Channel\Entity\Configuration\PlanningChannelConfigurationInterface;
  15. use Nellapp\Bundle\SDKBundle\Channel\Entity\Configuration\PlanningChannelConfigurationMethodTrait;
  16. use Nellapp\Bundle\SDKBundle\Sync\EntityKeys;
  17. use Symfony\Component\Serializer\Annotation as Serial;
  18. use Symfony\Component\Validator\Constraints as Assert;
  19. #[
  20.     ORM\Entity(repositoryClass: ChannelConfigurationRepository::class),
  21.     ORM\Table(name: 'channel_configuration')
  22. ]
  23. class ChannelConfiguration implements BaseChannelConfigurationInterface, PlanningChannelConfigurationInterface, ELearningChannelConfigurationInterface, SyncableInterface
  24. {
  25.     use BaseChannelConfigurationMethodTrait;
  26.     use PlanningChannelConfigurationMethodTrait;
  27.     use ELearningChannelConfigurationMethodTrait;
  28.     #[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer', nullable: false)]
  29.     #[Serial\Groups(['Sync'])]
  30.     private ?int $id = null;
  31.     #[ORM\OneToOne(mappedBy: 'configuration', targetEntity: Channel::class, fetch: 'EAGER')]
  32.     #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  33.     #[IdGroups(['Sync'])]
  34.     private ?Channel $channel = null;
  35.     #[ORM\Column(type: 'string', length: 50, nullable: true)]
  36.     #[Assert\Timezone(
  37.         message: 'channel.configuration.timezone.Timezone',
  38.     )]
  39.     #[Serial\Groups(['Sync'])]
  40.     private ?string $timezone = null;
  41.     #[ORM\ManyToOne(targetEntity: User::class)]
  42.     #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
  43.     #[IdGroups(['Sync'])]
  44.     private ?User $defaultReferralTrainer = null;
  45.     #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => false])]
  46.     private bool $showPositioningTestResults = false;
  47.     #[ORM\Column(type: 'simple_array', nullable: false, options: ['default' => '1,2,3,4,5'])]
  48.     #[Assert\NotBlank]
  49.     #[Serial\Groups(['Sync'])]
  50.     private array $planningDays = [1, 2, 3, 4, 5];
  51.     #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => false])]
  52.     #[Serial\Groups(['Sync'])]
  53.     private bool $enabledConference = false;
  54.     #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => false])]
  55.     private bool $enabledPartnerApiIndex = false;
  56.     #[ORM\ManyToOne(targetEntity: User::class, fetch: 'EAGER')]
  57.     #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
  58.     private ?User $commercialUser = null;
  59.     #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => false])]
  60.     #[Serial\Groups(['Sync'])]
  61.     private bool $enabledConferenceByDefaultOnEvents = false;
  62.     #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => false])]
  63.     #[Serial\Groups(['Sync'])]
  64.     private bool $enabledSigningModalityEvents = false;
  65.     #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => false])]
  66.     #[Serial\Groups(['Sync'])]
  67.     private bool $askForReferentCorrection = false;
  68.     #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => false])]
  69.     #[Serial\Groups(['Sync'])]
  70.     private bool $enableCustomTimeOnPracticalCase = false;
  71.     #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => false])]
  72.     #[Serial\Groups(['Sync'])]
  73.     private bool $enableBunnyStream = false;
  74.     #[ORM\Column(type: 'string', nullable: true)]
  75.     private ?string $zapierWebhookUrl = null;
  76.     #[ORM\Column(type: 'string', nullable: true)]
  77.     private ?string $pennylaneCustomerId = null;
  78.     #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => false])]
  79.     #[Serial\Groups(['Sync'])]
  80.     private bool $enabledCrm = false;
  81.     /** @var Collection<int, Service> */
  82.     #[ORM\ManyToMany(targetEntity: Service::class)]
  83.     #[ORM\JoinTable(name: 'channel_configuration_dsf_services')]
  84.     #[IdGroups(['Sync'])]
  85.     private Collection $dsfServicesToNotify;
  86.     public function __construct()
  87.     {
  88.         $this->dsfServicesToNotify = new ArrayCollection();
  89.     }
  90.     public static function getSyncKey(): string
  91.     {
  92.         return EntityKeys::CHANNEL_CONFIGURATION;
  93.     }
  94.     public function getSyncDisplayLabel(): string
  95.     {
  96.         return $this->getChannel() . ' - configuration';
  97.     }
  98.     public function getShowPositioningTestResults(): bool
  99.     {
  100.         return $this->showPositioningTestResults;
  101.     }
  102.     public function setShowPositioningTestResults(bool $showPositioningTestResults): static
  103.     {
  104.         $this->showPositioningTestResults = $showPositioningTestResults;
  105.         return $this;
  106.     }
  107.     public function toggleEnabledConference(): static
  108.     {
  109.         $this->enabledConference = !$this->enabledConference;
  110.         return $this;
  111.     }
  112.     public function isEnabledPartnerApiIndex(): bool
  113.     {
  114.         return $this->enabledPartnerApiIndex;
  115.     }
  116.     public function setEnabledPartnerApiIndex(bool $enabledPartnerApiIndex): static
  117.     {
  118.         $this->enabledPartnerApiIndex = $enabledPartnerApiIndex;
  119.         return $this;
  120.     }
  121.     public function toggleEnabledPartnerApiIndex(): static
  122.     {
  123.         $this->enabledPartnerApiIndex = !$this->enabledPartnerApiIndex;
  124.         return $this;
  125.     }
  126.     public function getCommercialUser(): ?User
  127.     {
  128.         return $this->commercialUser;
  129.     }
  130.     public function setCommercialUser(?User $commercialUser): ChannelConfiguration
  131.     {
  132.         $this->commercialUser = $commercialUser;
  133.         return $this;
  134.     }
  135.     public function getZapierWebhookUrl(): ?string
  136.     {
  137.         return $this->zapierWebhookUrl;
  138.     }
  139.     public function setZapierWebhookUrl(?string $zapierWebhookUrl): ChannelConfiguration
  140.     {
  141.         $this->zapierWebhookUrl = $zapierWebhookUrl;
  142.         return $this;
  143.     }
  144.     public function getPennylaneCustomerId(): ?string
  145.     {
  146.         return $this->pennylaneCustomerId;
  147.     }
  148.     public function setPennylaneCustomerId(?string $pennylaneCustomerId): ChannelConfiguration
  149.     {
  150.         $this->pennylaneCustomerId = $pennylaneCustomerId;
  151.         return $this;
  152.     }
  153.     public function toggleEnabledCrm(): static
  154.     {
  155.         $this->enabledCrm = !$this->enabledCrm;
  156.         return $this;
  157.     }
  158.     public function isEnableCustomTimeOnPracticalCase(): bool
  159.     {
  160.         return $this->enableCustomTimeOnPracticalCase;
  161.     }
  162.     public function setEnableCustomTimeOnPracticalCase(bool $enableCustomTimeOnPracticalCase): static
  163.     {
  164.         $this->enableCustomTimeOnPracticalCase = $enableCustomTimeOnPracticalCase;
  165.         return $this;
  166.     }
  167.     /** @return Collection<int, Service> */
  168.     public function getDsfServicesToNotify(): Collection
  169.     {
  170.         return $this->dsfServicesToNotify ?? new ArrayCollection();
  171.     }
  172.     public function addDsfServicesToNotify(Service $service): static
  173.     {
  174.         if (!$this->dsfServicesToNotify->contains($service)) {
  175.             $this->dsfServicesToNotify->add($service);
  176.         }
  177.         return $this;
  178.     }
  179.     public function removeDsfServicesToNotify(Service $service): static
  180.     {
  181.         $this->dsfServicesToNotify->removeElement($service);
  182.         return $this;
  183.     }
  184. }