src/Entity/Company.php line 93

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Annotation\ApiSubresource;
  6. use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
  7. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  8. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  9. use ApiPlatform\Core\Serializer\Filter\GroupFilter;
  10. use App\Entity\Traits\Address;
  11. use App\Repository\CompanyRepository;
  12. use App\Security\UserChecker;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\Common\Collections\Collection;
  15. use Doctrine\ORM\Mapping as ORM;
  16. use Gedmo\Mapping\Annotation as Gedmo;
  17. use Symfony\Component\HttpFoundation\File\File;
  18. use Symfony\Component\HttpFoundation\File\UploadedFile;
  19. use Symfony\Component\Serializer\Annotation\Groups;
  20. use Symfony\Component\Validator\Constraints as Assert;
  21. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  22. /**
  23.  * @ORM\InheritanceType("SINGLE_TABLE")
  24.  * @ORM\Entity(repositoryClass=CompanyRepository::class)
  25.  * @ApiResource(
  26.  *      normalizationContext={
  27.  *          "groups"={"company:read"}
  28.  *      },
  29.  *      denormalizationContext={
  30.  *          "groups"={"company:write"}
  31.  *      },
  32.  *      itemOperations={
  33.  *          "get",
  34.  *          "patch"={
  35.  *              "security"="is_granted('ROLE_ADMIN') or is_granted('ROLE_COMPANY')"
  36.  *          },
  37.  *          "delete"={
  38.  *              "security"="is_granted('ROLE_ADMIN')"
  39.  *          }
  40.  *      },
  41.  *      collectionOperations={
  42.  *          "get"={
  43.  *              "security"="is_granted('ROLE_ADMIN')"
  44.  *          }, 
  45.  *          "post"={
  46.  *              "security"="is_granted('ROLE_ADMIN')"
  47.  *          },
  48.  *          "export"={
  49.  *              "method"="GET",
  50.  *              "controller"="App\Controller\Api\CompanyController::extractCsv",
  51.  *              "path"="/companies/export",
  52.  *              "formats"={"csv"={"text/csv"}},
  53.  *              "pagination_enabled"=false,
  54.  *              "output"=Company::class,
  55.  *              "normalization_context"={"groups"={"company:export_csv:read"}}
  56.  *          },
  57.  *          "post_update"={
  58.  *              "security"="is_granted('ROLE_ADMIN')",
  59.  *              "path"="/companies/{id}",
  60.  *              "description"="Update a Company with method POST (using content-type: 'multipart')",
  61.  *              "method"="POST",
  62.  *              "controller"="App\Controller\Api\CompanyController::update"
  63.  *          }
  64.  *      }
  65.  * )
  66.  * @ApiFilter(SearchFilter::class, 
  67.  *      properties={
  68.  *          "name":"partial"
  69.  *      }
  70.  * )
  71.  * @ApiFilter(OrderFilter::class, 
  72.  *      properties={
  73.  *          "id", "name", "user.lastName", "status", "subscriptionEnd", "subscriptionStart", "clientsCount"
  74.  *      } 
  75.  * )
  76.  * @ApiFilter(GroupFilter::class, 
  77.  *      arguments={
  78.  *          "overrideDefaultGroups": true
  79.  *      }
  80.  * )
  81.  * @ApiFilter(PropertyFilter::class, 
  82.  *      arguments={
  83.  *          "parameterName"="fields", 
  84.  *          "overrideDefaultProperties"=true
  85.  *     }
  86.  * )
  87.  * @ORM\HasLifecycleCallbacks
  88.  * @Vich\Uploadable
  89.  */
  90. class Company
  91. {
  92.     const STATUS_ACTIVE 'active';
  93.     const STATUS_EXPIRED 'expired';
  94.     const STATUS_SUSPENDED 'suspended';
  95.     const STATUS_INACTIVE 'deactivated';
  96.     const MESSAGE_RESTRICTION 'restricted_msg';
  97.     const MESSAGE_QUOTAS 'restricted_msg';
  98.     const MESSAGE_DEFAULT 'default';
  99.     const STATUSES = [
  100.         self::STATUS_INACTIVE,
  101.         self::STATUS_EXPIRED,
  102.         self::STATUS_SUSPENDED,
  103.         self::STATUS_ACTIVE,
  104.     ];
  105.     use Address;
  106.     /**
  107.      * @ORM\Id
  108.      * @ORM\GeneratedValue
  109.      * @ORM\Column(type="integer")
  110.      * @Groups({"company:read", "team:read", "company:read:id", "client:read", "company_form", "teamplay:read", "video:read", "exclusion_video:read", "exclusion_category:read", "category:read", "program:read", "message:read"})
  111.      */
  112.     private $id;
  113.     /**
  114.      * @ORM\Column(type="string", length=255)
  115.      * @Assert\NotBlank
  116.      * @Groups({"company:read", "team:read", "company:read:name", "client:read", "company_form", "teamplay:read", "video:read", "exclusion_video:read", "exclusion_category:read", "category:read", "program:read", "message:read"})
  117.      */
  118.     private $name;
  119.     /**
  120.      * @ORM\Column(type="string", length=255, nullable=true)
  121.      * @Groups({"company:read:image", "client:read"})
  122.      */
  123.     private $image;
  124.     /**
  125.      * @Groups({"company:read", "company:read:imageUrl", "client:read", "user:read"})
  126.      * @var ?string
  127.      */
  128.     private $imageUrl "https://placehold.co/600x300";
  129.     /**
  130.      * @ORM\Column(type="datetime", nullable=true)
  131.      * @Gedmo\Timestampable(on="update")
  132.      */
  133.     private $updatedAt;
  134.     /**
  135.      * @ORM\OneToOne(targetEntity=User::class, inversedBy="company", cascade={"persist", "refresh", "remove"})
  136.      * @ORM\JoinColumn(nullable=false)
  137.      * @Assert\Valid()
  138.      * @Groups({"company:read", "company:read:user"})
  139.      */
  140.     private $user;
  141.     /**
  142.      * @Vich\UploadableField(mapping="specialists_images", fileNameProperty="image")
  143.      * @Assert\File(
  144.      *     mimeTypes={"image/jpeg", "image/gif", "image/png"},
  145.      *     maxSize="700Ki",
  146.      * )
  147.      * @var File
  148.      */
  149.     private $imageFile;
  150.     /**
  151.      * @ORM\OneToMany(targetEntity=Room::class, mappedBy="company", orphanRemoval=true, cascade={"persist", "refresh", "remove"}) 
  152.      * @Groups({"company:read", "company:read:rooms"})
  153.      */
  154.     private $rooms;
  155.     /**
  156.      * @ORM\OneToMany(targetEntity=Workshop::class, mappedBy="company", cascade={"persist", "refresh", "remove"})      
  157.      * @Groups({"company:read", "company:read:workshop"})   
  158.      */
  159.     private $workshops;
  160.     /**
  161.      * @ORM\OneToMany(targetEntity=Client::class, mappedBy="company", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  162.      * @Groups({"company:read", "company:read:clients"})
  163.      * @ApiSubresource(maxDepth=1)
  164.      */
  165.     private $clients;
  166.     /**
  167.      * @ORM\OneToMany(targetEntity=Event::class, mappedBy="company", cascade={"persist", "refresh", "remove"})
  168.      * @Groups({"company:read", "company:read:events"})
  169.      */
  170.     private $events;
  171.     /**
  172.      * @ORM\OneToMany(targetEntity=CompanyTag::class, mappedBy="company", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  173.      */
  174.     private $companyTags;
  175.     /**
  176.      * @ORM\Column(type="text", nullable=true)
  177.      * @Groups({"company:read", "company:read:presentation"})
  178.      */
  179.     private $presentation;
  180.     /**
  181.      * @ORM\Column(type="string", length=255, nullable=true)
  182.      * @Groups({"company:read", "company:read:presentationTitle"})
  183.      */
  184.     private $presentationTitle;
  185.     /**
  186.      * @ORM\Column(type="string", length=255, nullable=true)
  187.      * @Groups({"company:read", "company:read:siret"})
  188.      */
  189.     private $siret;
  190.     /**
  191.      * @ORM\Column(type="string", length=255, nullable=true)
  192.      * @Groups({"company:read", "company:read:phone"})
  193.      */
  194.     private $phone;
  195.     /**
  196.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  197.      * @Gedmo\Timestampable(on="create")
  198.      * @Groups({"company:read", "company:read:createdAt"})
  199.      */
  200.     private $createdAt;
  201.     /**
  202.      * @ORM\Column(type="string", length=255, nullable=true)
  203.      * @Groups({"company:read", "company:read:companyCode"})
  204.      */
  205.     private $companyCode;
  206.     /**
  207.      * @ORM\OneToMany(targetEntity=VisioEventPromotion::class, mappedBy="company", cascade={"persist", "refresh", "remove"})
  208.      */
  209.     private $visioEventPromotions;
  210.     /**
  211.      * @ORM\Column(type="boolean", options={"default": "1"})
  212.      * @Groups({"company:read", "company:read:visioAllowed"})
  213.      */
  214.     private $visioAllowed true;
  215.     /**
  216.      * @ORM\Column(type="boolean", options={"default": "1"})
  217.      * @Groups({"company:read", "company:read:visioPaymentAllowed"})
  218.      */
  219.     private $visioPaymentAllowed true;
  220.     /**
  221.      * @ORM\OneToMany(targetEntity=Specialist::class, mappedBy="affiliatedCompany", orphanRemoval=false)
  222.      */
  223.     private $affiliatedSpecialists;
  224.     /**
  225.      * @ORM\ManyToMany(targetEntity=Specialist::class, mappedBy="companies")
  226.      * @Groups({"company:read", "company:read:specialists"})
  227.      */
  228.     private $specialists;
  229.     /**
  230.      * @ORM\OneToMany(targetEntity=AffiliatedEventApplication::class, mappedBy="company", cascade={"persist", "refresh", "remove"})
  231.      */
  232.     private $affiliatedEventApplications;
  233.     /**
  234.      * @ORM\OneToMany(targetEntity=Segmentation::class, mappedBy="company", cascade={"persist", "refresh", "remove"})
  235.      * @Groups({"company:read", "company:read:segmentations"})
  236.      * @ApiSubresource(maxDepth=1)
  237.      */
  238.     private $segmentations;
  239.     /**
  240.      * @ORM\Column(type="boolean", options={"default": "0"})
  241.      * @Groups({"company:read", "client:read"})
  242.      */
  243.     private $forceSegmentation false;
  244.     /**
  245.      * @ORM\OneToMany(targetEntity=Configuration::class, mappedBy="company", cascade={"persist", "refresh", "remove"})
  246.      * @Groups({"company:read", "company:read:configurations"})
  247.      */
  248.     private $configurations;
  249.     // TV FIELDS
  250.     /**
  251.      * @ORM\ManyToOne(targetEntity=MediaObject::class)
  252.      * @Groups({"company:read", "company:write", "company:read:logo", "client:read"})
  253.      */
  254.     private $logo;
  255.     /**
  256.      * @ORM\Column(type="string", length=255, nullable=true)
  257.      * @Groups({"company:read", "company:write", "company:read:siren"})
  258.      */
  259.     private $siren;
  260.     /**
  261.      * @ORM\Column(type="string", length=255, options={"default": "active"})
  262.      * @Groups({"company:read", "company:write", "company:read:status"})
  263.      */
  264.     private $status self::STATUS_ACTIVE;
  265.     /**
  266.      * @ORM\Column(type="boolean", options={"default": "1"})
  267.      * @Groups({"company:read", "company:read:active"})
  268.      */
  269.     private $active true;
  270.     /**
  271.      * @ORM\Column(type="datetime", nullable=true)
  272.      * @Groups({"company:read", "company:write", "company:read:subscriptionStart"})
  273.      */
  274.     private $subscriptionStart;
  275.     /**
  276.      * @ORM\Column(type="datetime", nullable=true)
  277.      * @Groups({"company:read", "company:write", "company:read:subscriptionEnd"})
  278.      */
  279.     private $subscriptionEnd;
  280.     /**
  281.      * @ORM\Column(type="integer")
  282.      * @Groups({"company:read", "company:read:clientsCount"})
  283.      */
  284.     private $clientsCount 0;
  285.     /**
  286.      * Restriction messages if an User bypasses any restrictions
  287.      * A 'default' message key will be used if the message has not been customized
  288.      * @ORM\Column(type="array")
  289.      * @Groups({"company:read", "company:write"})
  290.      */
  291.     private $messages = [self::MESSAGE_DEFAULT => UserChecker::QUOTAS_MESSAGE];
  292.     /**
  293.      * Maximum users allowed for the company
  294.      * @ORM\Column(type="integer", nullable=true)
  295.      * @Groups({"company:read", "company:write", "company:read:maxClients"})
  296.      */
  297.     private $maxClients;
  298.     /**
  299.      * Forfait heure / forfait visionnage
  300.      * @ORM\Column(type="string", length=255, nullable=true)
  301.      * @Groups({"company:read", "company:write"})
  302.      */
  303.     private $plan;
  304.     /**
  305.      * Domain corresponding to this company ex:
  306.      * "orange.ulteam-tv.fr" will match company "Orange"
  307.      * @ORM\Column(type="string", length=255, nullable=true)
  308.      * @Groups({"company:read", "company:write"})
  309.      */
  310.     private $slug;
  311.     /**
  312.      * Restriction par IP
  313.      * @ORM\Column(type="array", nullable=true)
  314.      * @Groups({"company:read", "company:write"})
  315.      */
  316.     private $ips = [];
  317.     /**
  318.      * Restriction par domaine mail
  319.      * @ORM\Column(type="array", nullable=true)
  320.      * @Groups({"company:read", "company:write"})
  321.      */
  322.     private $domain = [];
  323.     /**
  324.      * Restriction heure de visionnage par utilisateur (5h)
  325.      * @ORM\Column(type="integer", nullable=true)
  326.      * @Groups({"company:read", "company:write"})
  327.      */
  328.     private $hourlyRestriction;
  329.     /**
  330.      * @ORM\Column(type="boolean", options={"default": "0"})
  331.      */
  332.     private $customizable false;
  333.     /**
  334.      * @ORM\Column(type="text", nullable=true)
  335.      * @Groups({"company:read", "company:write", "company:read:cms"})
  336.      */
  337.     private $cms;
  338.     /**
  339.      * @ORM\Column(type="string", length=255, nullable=true)
  340.      * @Groups({"company:read", "company:write", "company:read:cmsTitle"})
  341.      */
  342.     private $cmsTitle;
  343.     /**
  344.      * @ORM\ManyToOne(targetEntity=MediaObject::class)
  345.      * @Groups({"company:read", "company:write", "company:read:cmsImg"})
  346.      */
  347.     private $cmsImg;
  348.     /**
  349.      * @ORM\Column(type="text", nullable=true)
  350.      * @Groups({"company:read", "company:write", "company:read:cmsText"})
  351.      */
  352.     private $cmsText;
  353.     /**
  354.      * @ORM\Column(type="string", length=255, nullable=true)
  355.      * @Groups({"company:read", "company:write", "company:read:cmsCtaText"})
  356.      */
  357.     private $cmsCtaText;
  358.     /**
  359.      * @ORM\Column(type="string", length=255, nullable=true)
  360.      * @Groups({"company:read", "company:write", "company:read:cmsCtaUrl"})
  361.      */
  362.     private $cmsCtaUrl;
  363.     /**
  364.      * @ORM\Column(type="boolean", nullable=true)
  365.      * @Groups({"company:read", "company:write", "company:read:resaLinkActive"})
  366.      */
  367.     private $resaLinkActive;
  368.     /**
  369.      * @ORM\Column(type="string", length=255, nullable=true)
  370.      * @Groups({"company:read", "company:write", "company:read:email"})
  371.      */
  372.     private $email;
  373.     /**
  374.      * @ORM\OneToMany(targetEntity=Restriction::class, mappedBy="company", orphanRemoval=true, cascade={"remove"})
  375.      * @Groups({"company:read"})
  376.      */
  377.     private $restrictions;
  378.     /**
  379.      * @ORM\OneToMany(targetEntity=Order::class, mappedBy="company", cascade={"remove"})
  380.      * @Groups({"company:read"})
  381.      */
  382.     private $orders;
  383.     /**
  384.      * @ORM\OneToMany(targetEntity=Category::class, mappedBy="company", cascade={"persist", "refresh", "remove"})
  385.      */
  386.     private $categories;
  387.     /**
  388.      * @ORM\OneToMany(targetEntity=Channel::class, mappedBy="company", cascade={"persist", "refresh", "remove"})
  389.      */
  390.     private $channels;
  391.     /**
  392.      * @ORM\OneToMany(targetEntity=ExclusionsChannel::class, mappedBy="company", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  393.      */
  394.     private $exclusionsChannels;
  395.     /**
  396.      * @ORM\OneToMany(targetEntity=ExclusionsCategory::class, mappedBy="company", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  397.      */
  398.     private $exclusionsCategories;
  399.     /**
  400.      * @ORM\OneToMany(targetEntity=ExclusionsVideo::class, mappedBy="company", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  401.      */
  402.     private $exclusionsVideos;
  403.     /**
  404.      * @ORM\OneToMany(targetEntity=LogEmail::class, mappedBy="company", cascade={"persist", "refresh", "remove"})
  405.      */
  406.     private $logEmails;
  407.     /**
  408.      * @ORM\ManyToMany(targetEntity=Association::class)
  409.      * @Groups({"company:read", "company:write"})
  410.      * @ApiSubresource(maxDepth=1)
  411.      */
  412.     private $associations;
  413.     /**
  414.      * @ORM\OneToMany(targetEntity=Program::class, mappedBy="company", cascade={"persist", "refresh", "remove"})
  415.      */
  416.     private $programs;
  417.     /**
  418.      * @ORM\OneToMany(targetEntity=Team::class, mappedBy="company", cascade={"persist", "refresh", "remove"})
  419.      * @Groups({"company:read"})
  420.      * @ApiSubresource(maxDepth=1)
  421.      */
  422.     private $teams;
  423.     /**
  424.      * @ORM\OneToMany(targetEntity=Teamplay::class, mappedBy="company", cascade={"persist", "refresh", "remove"})
  425.      * @Groups({"company:read"})
  426.      */
  427.     private $teamplays;
  428.     /**
  429.      * @ORM\OneToMany(targetEntity=TeamplayChallenge::class, mappedBy="company", cascade={"persist", "refresh", "remove"})
  430.      * @Groups({"company:read"})
  431.      */
  432.     private $teamplayChallenges;
  433.     /**
  434.      * @ORM\OneToMany(targetEntity=TeamplayLog::class, mappedBy="company", cascade={"persist", "refresh", "remove"})
  435.      */
  436.     private $teamplayLogs;
  437.     /**
  438.      * @ORM\OneToMany(targetEntity=PedometerLog::class, mappedBy="company", cascade={"persist", "refresh", "remove"})
  439.      */
  440.     private $pedometerLogs;
  441.     /**
  442.      * @ORM\OneToMany(targetEntity=Log::class, mappedBy="company", cascade={"persist", "refresh", "remove"})
  443.      */
  444.     private $logs;
  445.     /**
  446.      * @ORM\OneToMany(targetEntity=UserNotification::class, mappedBy="company", cascade={"persist", "refresh", "remove"})
  447.      */
  448.     private $userNotifications;
  449.     
  450.     /**
  451.      * @ORM\OneToMany(targetEntity=Slide::class, mappedBy="company", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  452.      * @Groups({"company:read"})
  453.      */
  454.     private $slides;
  455.     /**
  456.      * @ORM\ManyToMany(targetEntity=Award::class, mappedBy="companies")
  457.      */
  458.     private $awards;
  459.     /**
  460.      * @ORM\OneToMany(targetEntity=AwardConfig::class, mappedBy="company", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  461.      */
  462.     private $awardConfigs;
  463.     /**
  464.      * @ORM\OneToOne(targetEntity=TvCompany::class, mappedBy="company", cascade={"persist", "refresh","remove"})
  465.      */
  466.     private $tvCompany;
  467.     /**
  468.      * @ORM\Column(type="boolean", options={"default": "1"})
  469.      * @Groups({"company:write",  "company:read", "company:read:live", "client:read"})
  470.      */
  471.     private $live true;
  472.     /**
  473.      * @ORM\Column(type="boolean", options={"default": "1"})
  474.      * @Groups({"company:write",  "company:read", "company:read:tv", "client:read"})
  475.      */
  476.     private $tv true;
  477.     /**
  478.      * @ORM\Column(type="string", length=255, nullable=true)
  479.      * @Groups({"company:read", "company:write", "company:read:consultLink", "client:read"})
  480.      */
  481.     private $consultLink;
  482.     public function __construct()
  483.     {
  484.         $this->rooms = new ArrayCollection();
  485.         $this->workshops = new ArrayCollection();
  486.         $this->clients = new ArrayCollection();
  487.         $this->events = new ArrayCollection();
  488.         $this->companyTags = new ArrayCollection();
  489.         $this->createdAt = new \DateTime();
  490.         $this->visioEventPromotions = new ArrayCollection();
  491.         $this->affiliatedSpecialists = new ArrayCollection();
  492.         $this->specialists = new ArrayCollection();
  493.         $this->affiliatedEventApplications = new ArrayCollection();
  494.         $this->segmentations = new ArrayCollection();
  495.         $this->configurations = new ArrayCollection();
  496.         $this->restrictions = new ArrayCollection();
  497.         $this->orders = new ArrayCollection();
  498.         $this->categories = new ArrayCollection();
  499.         $this->channels = new ArrayCollection();
  500.         $this->exclusionsChannels = new ArrayCollection();
  501.         $this->exclusionsCategories = new ArrayCollection();
  502.         $this->exclusionsVideos = new ArrayCollection();
  503.         $this->logEmails = new ArrayCollection();
  504.         $this->associations = new ArrayCollection();
  505.         $this->programs = new ArrayCollection();
  506.         $this->teams = new ArrayCollection();
  507.         $this->teamplays = new ArrayCollection();
  508.         $this->teamplayChallenges = new ArrayCollection();
  509.         $this->teamplayLogs = new ArrayCollection();
  510.         $this->pedometerLogs = new ArrayCollection();
  511.         $this->logs = new ArrayCollection();
  512.         $this->userNotifications = new ArrayCollection();
  513.         $this->slides = new ArrayCollection();
  514.         $this->awards = new ArrayCollection();
  515.         $this->awardConfigs = new ArrayCollection();
  516.     }
  517.     public function getId(): ?int
  518.     {
  519.         return $this->id;
  520.     }
  521.     public function getName(): ?string
  522.     {
  523.         return $this->name;
  524.     }
  525.     public function setName(?string $name): self
  526.     {
  527.         $this->name $name;
  528.         if ($this->user instanceof User){
  529.             $this->user->setName($name);
  530.         }
  531.         return $this;
  532.     }
  533.     public function getImage(): ?string
  534.     {
  535.         return $this->image;
  536.     }
  537.     public function setImage(?string $image): self
  538.     {
  539.         $this->image $image;
  540.         return $this;
  541.     }
  542.     public function getUpdatedAt(): ?\DateTime
  543.     {
  544.         return $this->updatedAt;
  545.     }
  546.     public function setUpdatedAt(?\DateTime $updatedAt): self
  547.     {
  548.         $this->updatedAt $updatedAt;
  549.         return $this;
  550.     }
  551.     public function getUser(): ?User
  552.     {
  553.         return $this->user;
  554.     }
  555.     public function setUser(?User $user): self
  556.     {
  557.         $this->user $user;
  558.         $this->setName($this->getName());
  559.         return $this;
  560.     }
  561.     /**
  562.      * @return File|null
  563.      */
  564.     public function getImageFile(): ?File
  565.     {
  566.         return $this->imageFile;
  567.     }
  568.     /**
  569.      * @param File|null $imageFile
  570.      * @return Company
  571.      */
  572.     public function setImageFile(?File $imageFile null): self
  573.     {
  574.         $this->imageFile $imageFile;
  575.         if ($imageFile) {
  576.             // if 'updatedAt' is not defined in your entity, use another property
  577.             $this->updatedAt = new \DateTime('now');
  578.         }
  579.         return $this;
  580.     }
  581.     /**
  582.      * @return Collection|Room[]
  583.      */
  584.     public function getRooms(): Collection
  585.     {
  586.         return $this->rooms;
  587.     }
  588.     public function addRoom(Room $room): self
  589.     {
  590.         if (!$this->rooms->contains($room)) {
  591.             $this->rooms[] = $room;
  592.             $room->setCompany($this);
  593.         }
  594.         return $this;
  595.     }
  596.     public function removeRoom(Room $room): self
  597.     {
  598.         if ($this->rooms->removeElement($room)) {
  599.             // set the owning side to null (unless already changed)
  600.             if ($room->getCompany() === $this) {
  601.                 $room->setCompany(null);
  602.             }
  603.         }
  604.         return $this;
  605.     }
  606.     /**
  607.      * @return Collection|Workshop[]
  608.      */
  609.     public function getWorkshops(): Collection
  610.     {
  611.         return $this->workshops;
  612.     }
  613.     public function addWorkshop(Workshop $workshop): self
  614.     {
  615.         if (!$this->workshops->contains($workshop)) {
  616.             $this->workshops[] = $workshop;
  617.             $workshop->setCompany($this);
  618.         }
  619.         return $this;
  620.     }
  621.     public function removeWorkshop(Workshop $workshop): self
  622.     {
  623.         if ($this->workshops->removeElement($workshop)) {
  624.             // set the owning side to null (unless already changed)
  625.             if ($workshop->getCompany() === $this) {
  626.                 $workshop->setCompany(null);
  627.             }
  628.         }
  629.         return $this;
  630.     }
  631.     /**
  632.      * @ORM\PrePersist()
  633.      */
  634.     public function prePersist()
  635.     {
  636.         $this->user->setCategory(User::GROUP_COMPANY);
  637.         $this->user->addRole(User::ROLE_COMPANY);
  638.     }
  639.     public function __toString()
  640.     {
  641.         return $this->name??'';
  642.     }
  643.     /**
  644.      * @return Collection|Client[]
  645.      */
  646.     public function getClients(): Collection
  647.     {
  648.         return $this->clients;
  649.     }
  650.     public function addClient(Client $client): self
  651.     {
  652.         if (!$this->clients->contains($client)) {
  653.             $this->clients[] = $client;
  654.             $client->setCompany($this);
  655.         }
  656.         return $this;
  657.     }
  658.     public function removeClient(Client $client): self
  659.     {
  660.         if ($this->clients->removeElement($client)) {
  661.             // set the owning side to null (unless already changed)
  662.             if ($client->getCompany() === $this) {
  663.                 $client->setCompany(null);
  664.             }
  665.         }
  666.         return $this;
  667.     }
  668.     /**
  669.      * @return Collection|Event[]
  670.      */
  671.     public function getEvents(): Collection
  672.     {
  673.         return $this->events;
  674.     }
  675.     public function addEvent(Event $event): self
  676.     {
  677.         if (!$this->events->contains($event)) {
  678.             $this->events[] = $event;
  679.             $event->setCompany($this);
  680.         }
  681.         return $this;
  682.     }
  683.     public function removeEvent(Event $event): self
  684.     {
  685.         if ($this->events->removeElement($event)) {
  686.             // set the owning side to null (unless already changed)
  687.             if ($event->getCompany() === $this) {
  688.                 $event->setCompany(null);
  689.             }
  690.         }
  691.         return $this;
  692.     }
  693.     /**
  694.      * @return Collection|CompanyTag[]
  695.      */
  696.     public function getCompanyTags(): Collection
  697.     {
  698.         return $this->companyTags;
  699.     }
  700.     public function setCompanyTags(array $companyTags): self
  701.     {
  702.         $this->companyTags = new ArrayCollection();
  703.         if (is_array($companyTags)){
  704.             $this->companyTags = new ArrayCollection($companyTags);
  705.         }
  706.         return $this;
  707.     }
  708.     public function addCompanyTag(CompanyTag $companyTag): self
  709.     {
  710.         if (!$this->companyTags->contains($companyTag)) {
  711.             $this->companyTags[] = $companyTag;
  712.             $companyTag->setCompany($this);
  713.         }
  714.         return $this;
  715.     }
  716.     public function removeCompanyTag(CompanyTag $companyTag): self
  717.     {
  718.         if ($this->companyTags->removeElement($companyTag)) {
  719.             // set the owning side to null (unless already changed)
  720.             if ($companyTag->getCompany() === $this) {
  721.                 $companyTag->setCompany(null);
  722.             }
  723.         }
  724.         return $this;
  725.     }
  726.     public function getPresentation(): ?string
  727.     {
  728.         return $this->presentation;
  729.     }
  730.     public function setPresentation(?string $presentation): self
  731.     {
  732.         $this->presentation $presentation;
  733.         return $this;
  734.     }
  735.     public function getPresentationTitle(): ?string
  736.     {
  737.         return $this->presentationTitle;
  738.     }
  739.     public function setPresentationTitle(?string $presentationTitle): self
  740.     {
  741.         $this->presentationTitle $presentationTitle;
  742.         return $this;
  743.     }
  744.     public function getSiret(): ?string
  745.     {
  746.         return $this->siret;
  747.     }
  748.     public function setSiret(?string $siret): self
  749.     {
  750.         $this->siret $siret;
  751.         return $this;
  752.     }
  753.     public function getPhone(): ?string
  754.     {
  755.         return $this->phone;
  756.     }
  757.     public function setPhone(?string $phone): self
  758.     {
  759.         $this->phone $phone;
  760.         return $this;
  761.     }
  762.     public function getCreatedAt(): ?\DateTime
  763.     {
  764.         return $this->createdAt;
  765.     }
  766.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  767.     {
  768.         $this->createdAt $createdAt;
  769.         return $this;
  770.     }
  771.     public function getCompanyCode(): ?string
  772.     {
  773.         return $this->companyCode;
  774.     }
  775.     public function setCompanyCode(?string $companyCode): self
  776.     {
  777.         $this->companyCode $companyCode;
  778.         return $this;
  779.     }
  780.     /**
  781.      * @return Collection<int, VisioEventPromotion>
  782.      */
  783.     public function getVisioEventPromotions(): Collection
  784.     {
  785.         return $this->visioEventPromotions;
  786.     }
  787.     public function addVisioEventPromotion(VisioEventPromotion $visioEventPromotion): self
  788.     {
  789.         if (!$this->visioEventPromotions->contains($visioEventPromotion)) {
  790.             $this->visioEventPromotions[] = $visioEventPromotion;
  791.             $visioEventPromotion->setCompany($this);
  792.         }
  793.         return $this;
  794.     }
  795.     public function removeVisioEventPromotion(VisioEventPromotion $visioEventPromotion): self
  796.     {
  797.         if ($this->visioEventPromotions->removeElement($visioEventPromotion)) {
  798.             // set the owning side to null (unless already changed)
  799.             if ($visioEventPromotion->getCompany() === $this) {
  800.                 $visioEventPromotion->setCompany(null);
  801.             }
  802.         }
  803.         return $this;
  804.     }
  805.     public function getVisioAllowed(): ?bool
  806.     {
  807.         return $this->visioAllowed;
  808.     }
  809.     public function setVisioAllowed(?bool $visioAllowed): self
  810.     {
  811.         $this->visioAllowed $visioAllowed;
  812.         return $this;
  813.     }
  814.     public function getVisioPaymentAllowed(): ?bool
  815.     {
  816.         return $this->visioPaymentAllowed;
  817.     }
  818.     public function setVisioPaymentAllowed(bool $visioPaymentAllowed): self
  819.     {
  820.         $this->visioPaymentAllowed $visioPaymentAllowed;
  821.         return $this;
  822.     }
  823.     /**
  824.      * @return Collection<int, Specialist>
  825.      */
  826.     public function getAffiliatedSpecialists(): Collection
  827.     {
  828.         return $this->affiliatedSpecialists;
  829.     }
  830.     public function addAffiliatedSpecialist(Specialist $affiliatedSpecialist): self
  831.     {
  832.         if (!$this->affiliatedSpecialists->contains($affiliatedSpecialist)) {
  833.             $this->affiliatedSpecialists[] = $affiliatedSpecialist;
  834.             $affiliatedSpecialist->setAffiliatedCompany($this);
  835.         }
  836.         return $this;
  837.     }
  838.     public function removeAffiliatedSpecialist(Specialist $affiliatedSpecialist): self
  839.     {
  840.         if ($this->affiliatedSpecialists->removeElement($affiliatedSpecialist)) {
  841.             // set the owning side to null (unless already changed)
  842.             if ($affiliatedSpecialist->getAffiliatedCompany() === $this) {
  843.                 $affiliatedSpecialist->setAffiliatedCompany(null);
  844.             }
  845.         }
  846.         return $this;
  847.     }
  848.     /**
  849.      * @return Collection<int, Specialist>
  850.      */
  851.     public function getSpecialists(): Collection
  852.     {
  853.         return $this->specialists;
  854.     }
  855.     public function addSpecialist(Specialist $specialist): self
  856.     {
  857.         if (!$this->specialists->contains($specialist)) {
  858.             $this->specialists[] = $specialist;
  859.             $specialist->addCompany($this);
  860.         }
  861.         return $this;
  862.     }
  863.     public function removeSpecialist(Specialist $specialist): self
  864.     {
  865.         if ($this->specialists->removeElement($specialist)) {
  866.             $specialist->removeCompany($this);
  867.         }
  868.         return $this;
  869.     }
  870.     /**
  871.      * @return Collection<int, AffiliatedEventApplication>
  872.      */
  873.     public function getAffiliatedEventApplications(): Collection
  874.     {
  875.         return $this->affiliatedEventApplications;
  876.     }
  877.     public function addAffiliatedEventApplication(AffiliatedEventApplication $affiliatedEventApplication): self
  878.     {
  879.         if (!$this->affiliatedEventApplications->contains($affiliatedEventApplication)) {
  880.             $this->affiliatedEventApplications[] = $affiliatedEventApplication;
  881.             $affiliatedEventApplication->setCompany($this);
  882.         }
  883.         return $this;
  884.     }
  885.     public function removeAffiliatedEventApplication(AffiliatedEventApplication $affiliatedEventApplication): self
  886.     {
  887.         if ($this->affiliatedEventApplications->removeElement($affiliatedEventApplication)) {
  888.             // set the owning side to null (unless already changed)
  889.             if ($affiliatedEventApplication->getCompany() === $this) {
  890.                 $affiliatedEventApplication->setCompany(null);
  891.             }
  892.         }
  893.         return $this;
  894.     }
  895.     /**
  896.      * @return Collection<int, Segmentation>
  897.      */
  898.     public function getSegmentations(): Collection
  899.     {
  900.         return $this->segmentations;
  901.     }
  902.     public function addSegmentation(Segmentation $segmentation): self
  903.     {
  904.         if (!$this->segmentations->contains($segmentation)) {
  905.             $this->segmentations[] = $segmentation;
  906.             $segmentation->setCompany($this);
  907.         }
  908.         return $this;
  909.     }
  910.     public function removeSegmentation(Segmentation $segmentation): self
  911.     {
  912.         if ($this->segmentations->removeElement($segmentation)) {
  913.             // set the owning side to null (unless already changed)
  914.             if ($segmentation->getCompany() === $this) {
  915.                 $segmentation->setCompany(null);
  916.             }
  917.         }
  918.         return $this;
  919.     }
  920.     public function getForceSegmentation(): ?bool
  921.     {
  922.         return $this->forceSegmentation;
  923.     }
  924.     public function setForceSegmentation(?bool $forceSegmentation): self
  925.     {
  926.         $this->forceSegmentation $forceSegmentation;
  927.         return $this;
  928.     }
  929.     /**
  930.      * @return Collection<int, Configuration>
  931.      */
  932.     public function getConfigurations(): Collection
  933.     {
  934.         return $this->configurations;
  935.     }
  936.     public function addConfiguration(Configuration $configuration): self
  937.     {
  938.         if (!$this->configurations->contains($configuration)) {
  939.             $this->configurations[] = $configuration;
  940.             $configuration->setCompany($this);
  941.         }
  942.         return $this;
  943.     }
  944.     public function removeConfiguration(Configuration $configuration): self
  945.     {
  946.         if ($this->configurations->removeElement($configuration)) {
  947.             // set the owning side to null (unless already changed)
  948.             if ($configuration->getCompany() === $this) {
  949.                 $configuration->setCompany(null);
  950.             }
  951.         }
  952.         return $this;
  953.     }
  954.     public function getLogo(): ?MediaObject
  955.     {
  956.         return $this->logo;
  957.     }
  958.     public function setLogo(?MediaObject $logo): self
  959.     {
  960.         $this->logo $logo;
  961.         return $this;
  962.     }
  963.     /**
  964.      * @Groups({"company:write"})
  965.      */
  966.     public function setLogoFile($file null): self
  967.     {
  968.         if($file instanceof UploadedFile) {
  969.             $logo = empty($this->logo) ? new MediaObject $this->logo;
  970.             $logo->setFile($file);
  971.             $this->setLogo($logo);
  972.         }
  973.         return $this;
  974.     }
  975.     public function getSiren(): ?string
  976.     {
  977.         return $this->siren;
  978.     }
  979.     public function setSiren(?string $siren): self
  980.     {
  981.         $this->siren $siren;
  982.         return $this;
  983.     }
  984.     public function setStatus(?string $status): self
  985.     {
  986.         $this->status $status;
  987.         if (in_array($this->status, [self::STATUS_SUSPENDEDself::STATUS_EXPIREDself::STATUS_INACTIVE])) {
  988.             $this->active false;
  989.         } else {
  990.             $this->active true;
  991.         }
  992.         return $this;
  993.     }
  994.     /**
  995.      * @return string
  996.      */
  997.     public function getStatus(): string
  998.     {
  999.         return $this->status;
  1000.     }
  1001.     public function getActive(): ?bool
  1002.     {
  1003.         return $this->active;
  1004.     }
  1005.     public function isActive(): ?bool
  1006.     {
  1007.         return $this->active;
  1008.     }
  1009.     public function setActive(?bool $active): self
  1010.     {
  1011.         $this->active $active;
  1012.         return $this;
  1013.     }
  1014.     public function getSubscriptionStart(): ?\DateTimeInterface
  1015.     {
  1016.         return $this->subscriptionStart;
  1017.     }
  1018.     public function setSubscriptionStart(?\DateTimeInterface $subscriptionStart): self
  1019.     {
  1020.         $this->subscriptionStart $subscriptionStart;
  1021.         return $this;
  1022.     }
  1023.     public function getSubscriptionEnd(): ?\DateTimeInterface
  1024.     {
  1025.         return $this->subscriptionEnd;
  1026.     }
  1027.     public function setSubscriptionEnd(?\DateTimeInterface $subscriptionEnd): self
  1028.     {
  1029.         $this->subscriptionEnd $subscriptionEnd;
  1030.         return $this;
  1031.     }
  1032.     /**
  1033.      * Gets the active order no more than an order can be active at a time for a company
  1034.      * @return Order|null
  1035.      */
  1036.     public function getActiveOrder(): ?Order
  1037.     {
  1038.         foreach ($this->orders as $order) {
  1039.             if ($order instanceof Order && $order->getActive()) {
  1040.                 return $order;
  1041.             }
  1042.         }
  1043.         return null;
  1044.     }
  1045.     /**
  1046.      * Updates the entity including users count, created at and updated at elements
  1047.      * and the start and the end of the subscription
  1048.      * @return company
  1049.      * @ORM\PrePersist
  1050.      */
  1051.     public function updateEntity(): self
  1052.     {
  1053.         $this->updateSubscription();
  1054.         $this->updateStatus();
  1055.         $this->updateClientsCount();
  1056.         $this->updatedAt = new \DateTime();
  1057.         return $this;
  1058.     }
  1059.     /**
  1060.      * Updates the count of the company users
  1061.      */
  1062.     private function updateClientsCount()
  1063.     {
  1064.         $this->clientsCount $this->clients->count();
  1065.     }
  1066.     /**
  1067.      * Updates subscription dates
  1068.      */
  1069.     private function updateSubscription()
  1070.     {
  1071.         $order $this->getActiveOrder();
  1072.         if ($order instanceof Order) {
  1073.             $this->subscriptionEnd $order->getEnd();
  1074.             $this->subscriptionStart $order->getStart();
  1075.         }
  1076.     }
  1077.     /**
  1078.      * Updates the status of the company
  1079.      */
  1080.     private function updateStatus()
  1081.     {
  1082.         $ret self::STATUS_ACTIVE;
  1083.         if ($this->subscriptionEnd < (new \DateTime())) {
  1084.             $ret self::STATUS_EXPIRED;
  1085.         }
  1086.         if (!$this->active) {
  1087.             $ret self::STATUS_SUSPENDED;
  1088.         }
  1089.         $this->status $ret;
  1090.     }
  1091.     public function getMessages(): ?array
  1092.     {
  1093.         if (!is_array($this->messages)) {
  1094.             $this->messages = [];
  1095.         }
  1096.         return $this->messages;
  1097.     }
  1098.     /**
  1099.      * Gets a message if it exists
  1100.      * @param string $key
  1101.      * @return string|null
  1102.      */
  1103.     public function getMessage(string $key): ?string
  1104.     {
  1105.         $_messages $this->getMessages();
  1106.         return (!empty($_messages[$key])) ? $_messages[$key] : null;
  1107.     }
  1108.     public function setMessages(?array $messages): self
  1109.     {
  1110.         $this->messages $messages;
  1111.         return $this;
  1112.     }
  1113.     public function getMaxClients(): ?int
  1114.     {
  1115.         return $this->maxClients;
  1116.     }
  1117.     public function setMaxClients(?int $maxClients): self
  1118.     {
  1119.         $this->maxClients $maxClients;
  1120.         return $this;
  1121.     }
  1122.     public function getPlan(): ?string
  1123.     {
  1124.         return $this->plan;
  1125.     }
  1126.     public function setPlan(?string $plan): self
  1127.     {
  1128.         $this->plan $plan;
  1129.         return $this;
  1130.     }
  1131.     public function getSlug(): ?string
  1132.     {
  1133.         return $this->slug;
  1134.     }
  1135.     public function setSlug(?string $slug): self
  1136.     {
  1137.         $this->slug $slug;
  1138.         return $this;
  1139.     }
  1140.     public function getIps(): ?array
  1141.     {
  1142.         return $this->ips;
  1143.     }
  1144.     public function setIps(?array $ips): self
  1145.     {
  1146.         $this->ips $ips;
  1147.         return $this;
  1148.     }
  1149.     public function getDomain(): ?array
  1150.     {
  1151.         return $this->domain;
  1152.     }
  1153.     public function setDomain(?array $domain): self
  1154.     {
  1155.         $this->domain $domain;
  1156.         return $this;
  1157.     }
  1158.     public function getHourlyRestriction(): ?int
  1159.     {
  1160.         return $this->hourlyRestriction;
  1161.     }
  1162.     public function setHourlyRestriction($hourlyRestriction): self
  1163.     {
  1164.         if (is_bool($hourlyRestriction)) {
  1165.             if ($hourlyRestriction) {
  1166.                 $hourlyRestriction 5;
  1167.             } else {
  1168.                 $hourlyRestriction 0;
  1169.             }
  1170.         }
  1171.         $this->hourlyRestriction $hourlyRestriction;
  1172.         return $this;
  1173.     }
  1174.     public function getCustomizable(): ?bool
  1175.     {
  1176.         return $this->customizable;
  1177.     }
  1178.     public function isCustomizable(): bool
  1179.     {
  1180.         return boolval($this->customizable);
  1181.     }
  1182.     public function setCustomizable(bool $customizable): self
  1183.     {
  1184.         $this->customizable $customizable;
  1185.         return $this;
  1186.     }
  1187.     public function getCms(): ?string
  1188.     {
  1189.         return $this->cms;
  1190.     }
  1191.     public function setCms(?string $cms): self
  1192.     {
  1193.         $this->cms $cms;
  1194.         return $this;
  1195.     }
  1196.     public function getCmsTitle(): ?string
  1197.     {
  1198.         return $this->cmsTitle;
  1199.     }
  1200.     public function setCmsTitle(?string $cmsTitle): self
  1201.     {
  1202.         $this->cmsTitle $cmsTitle;
  1203.         return $this;
  1204.     }
  1205.     public function getCmsImg(): ?MediaObject
  1206.     {
  1207.         return $this->cmsImg;
  1208.     }
  1209.     public function setCmsImg(?MediaObject $cmsImg): self
  1210.     {
  1211.         $this->cmsImg $cmsImg;
  1212.         return $this;
  1213.     }
  1214.     /**
  1215.      * @Groups({"company:write"})
  1216.      */
  1217.     public function setCmsImgFile($file null): self
  1218.     {
  1219.         if($file instanceof UploadedFile) {
  1220.             $cmsImg = empty($this->cmsImg) ? new MediaObject $this->cmsImg;
  1221.             $cmsImg->setFile($file);
  1222.             $this->setCmsImg($cmsImg);
  1223.         }
  1224.         return $this;
  1225.     }
  1226.     public function getCmsText(): ?string
  1227.     {
  1228.         return $this->cmsText;
  1229.     }
  1230.     public function setCmsText(?string $cmsText): self
  1231.     {
  1232.         $this->cmsText $cmsText;
  1233.         return $this;
  1234.     }
  1235.     public function getCmsCtaText(): ?string
  1236.     {
  1237.         return $this->cmsCtaText;
  1238.     }
  1239.     public function setCmsCtaText(?string $cmsCtaText): self
  1240.     {
  1241.         $this->cmsCtaText $cmsCtaText;
  1242.         return $this;
  1243.     }
  1244.     public function getCmsCtaUrl(): ?string
  1245.     {
  1246.         return $this->cmsCtaUrl;
  1247.     }
  1248.     public function setCmsCtaUrl(?string $cmsCtaUrl): self
  1249.     {
  1250.         $this->cmsCtaUrl $cmsCtaUrl;
  1251.         return $this;
  1252.     }
  1253.     public function getResaLinkActive(): ?bool
  1254.     {
  1255.         return $this->resaLinkActive;
  1256.     }
  1257.     public function setResaLinkActive(?bool $resaLinkActive): self
  1258.     {
  1259.         $this->resaLinkActive $resaLinkActive;
  1260.         return $this;
  1261.     }
  1262.     public function getEmail(): ?string
  1263.     {
  1264.         return $this->email;
  1265.     }
  1266.     public function setEmail(?string $email): self
  1267.     {
  1268.         $this->email $email;
  1269.         return $this;
  1270.     }
  1271.     /**
  1272.      * @return Collection|Restriction[]
  1273.      */
  1274.     public function getRestrictions(): Collection
  1275.     {
  1276.         return $this->restrictions;
  1277.     }
  1278.     public function addRestriction(Restriction $restriction): self
  1279.     {
  1280.         if (!$this->restrictions->contains($restriction)) {
  1281.             $this->restrictions[] = $restriction;
  1282.             $restriction->setCompany($this);
  1283.         }
  1284.         return $this;
  1285.     }
  1286.     public function removeRestriction(Restriction $restriction): self
  1287.     {
  1288.         if ($this->restrictions->removeElement($restriction)) {
  1289.             // set the owning side to null (unless already changed)
  1290.             if ($restriction->getCompany() === $this) {
  1291.                 $restriction->setCompany(null);
  1292.             }
  1293.         }
  1294.         return $this;
  1295.     }
  1296.     /**
  1297.      * @return Collection|Order[]
  1298.      */
  1299.     public function getOrders(): Collection
  1300.     {
  1301.         return $this->orders;
  1302.     }
  1303.     public function addOrder(Order $order): self
  1304.     {
  1305.         if (!$this->orders->contains($order)) {
  1306.             $this->orders[] = $order;
  1307.             $order->setCompany($this);
  1308.         }
  1309.         return $this;
  1310.     }
  1311.     public function removeOrder(Order $order): self
  1312.     {
  1313.         if ($this->orders->removeElement($order)) {
  1314.             // set the owning side to null (unless already changed)
  1315.             if ($order->getCompany() === $this) {
  1316.                 $order->setCompany(null);
  1317.             }
  1318.         }
  1319.         return $this;
  1320.     }
  1321.     /**
  1322.      * @return Collection|Category[]
  1323.      */
  1324.     public function getCategories(): Collection
  1325.     {
  1326.         return $this->categories;
  1327.     }
  1328.     public function addCategory(Category $category): self
  1329.     {
  1330.         if (!$this->categories->contains($category)) {
  1331.             $this->categories[] = $category;
  1332.             $category->setCompany($this);
  1333.         }
  1334.         return $this;
  1335.     }
  1336.     public function removeCategory(Category $category): self
  1337.     {
  1338.         if ($this->categories->removeElement($category)) {
  1339.             // set the owning side to null (unless already changed)
  1340.             if ($category->getCompany() === $this) {
  1341.                 $category->setCompany(null);
  1342.             }
  1343.         }
  1344.         return $this;
  1345.     }
  1346.     /**
  1347.      * @return Collection|Channel[]
  1348.      */
  1349.     public function getChannels(): Collection
  1350.     {
  1351.         return $this->channels;
  1352.     }
  1353.     public function addChannel(Channel $channel): self
  1354.     {
  1355.         if (!$this->channels->contains($channel)) {
  1356.             $this->channels[] = $channel;
  1357.             $channel->setCompany($this);
  1358.         }
  1359.         return $this;
  1360.     }
  1361.     public function removeChannel(Channel $channel): self
  1362.     {
  1363.         if ($this->channels->removeElement($channel)) {
  1364.             // set the owning side to null (unless already changed)
  1365.             if ($channel->getCompany() === $this) {
  1366.                 $channel->setCompany(null);
  1367.             }
  1368.         }
  1369.         return $this;
  1370.     }
  1371.     /**
  1372.      * @return Collection|ExclusionsChannel[]
  1373.      */
  1374.     public function getExclusionsChannels(): Collection
  1375.     {
  1376.         return $this->exclusionsChannels;
  1377.     }
  1378.     public function addExclusionsChannel(ExclusionsChannel $exclusionsChannel): self
  1379.     {
  1380.         if (!$this->exclusionsChannels->contains($exclusionsChannel)) {
  1381.             $this->exclusionsChannels[] = $exclusionsChannel;
  1382.             $exclusionsChannel->setCompany($this);
  1383.         }
  1384.         return $this;
  1385.     }
  1386.     public function removeExclusionsChannel(ExclusionsChannel $exclusionsChannel): self
  1387.     {
  1388.         if ($this->exclusionsChannels->removeElement($exclusionsChannel)) {
  1389.             // set the owning side to null (unless already changed)
  1390.             if ($exclusionsChannel->getCompany() === $this) {
  1391.                 $exclusionsChannel->setCompany(null);
  1392.             }
  1393.         }
  1394.         return $this;
  1395.     }
  1396.     /**
  1397.      * @return Collection|ExclusionsCategory[]
  1398.      */
  1399.     public function getExclusionsCategories(): Collection
  1400.     {
  1401.         return $this->exclusionsCategories;
  1402.     }
  1403.     public function addExclusionsCategory(ExclusionsCategory $exclusionsCategory): self
  1404.     {
  1405.         if (!$this->exclusionsCategories->contains($exclusionsCategory)) {
  1406.             $this->exclusionsCategories[] = $exclusionsCategory;
  1407.             $exclusionsCategory->setCompany($this);
  1408.         }
  1409.         return $this;
  1410.     }
  1411.     public function removeExclusionsCategory(ExclusionsCategory $exclusionsCategory): self
  1412.     {
  1413.         if ($this->exclusionsCategories->removeElement($exclusionsCategory)) {
  1414.             // set the owning side to null (unless already changed)
  1415.             if ($exclusionsCategory->getCompany() === $this) {
  1416.                 $exclusionsCategory->setCompany(null);
  1417.             }
  1418.         }
  1419.         return $this;
  1420.     }
  1421.     /**
  1422.      * @return Collection|ExclusionsVideo[]
  1423.      */
  1424.     public function getExclusionsVideos(): Collection
  1425.     {
  1426.         return $this->exclusionsVideos;
  1427.     }
  1428.     public function addExclusionsVideo(ExclusionsVideo $exclusionsVideo): self
  1429.     {
  1430.         if (!$this->exclusionsVideos->contains($exclusionsVideo)) {
  1431.             $this->exclusionsVideos[] = $exclusionsVideo;
  1432.             $exclusionsVideo->setCompany($this);
  1433.         }
  1434.         return $this;
  1435.     }
  1436.     public function removeExclusionsVideo(ExclusionsVideo $exclusionsVideo): self
  1437.     {
  1438.         if ($this->exclusionsVideos->removeElement($exclusionsVideo)) {
  1439.             // set the owning side to null (unless already changed)
  1440.             if ($exclusionsVideo->getCompany() === $this) {
  1441.                 $exclusionsVideo->setCompany(null);
  1442.             }
  1443.         }
  1444.         return $this;
  1445.     }
  1446.     /**
  1447.      * Permet de savoir si l'abonnement est actif ou non.
  1448.      * @return bool
  1449.      */
  1450.     public function hasCurrentSubscription(): bool
  1451.     {
  1452.         $hasCurrentSubscription false;
  1453.         if($this->checkSubscriptionsDates(new \DateTime("now"))) {
  1454.             $hasCurrentSubscription true;
  1455.         }
  1456.         return $hasCurrentSubscription;
  1457.     }
  1458.     public function checkSubscriptionsDates(\DateTime $today)
  1459.     {
  1460.         return $today >= $this->subscriptionStart && $today <= $this->subscriptionEnd;
  1461.     }
  1462.     /**
  1463.      * @return Collection|LogEmail[]
  1464.      */
  1465.     public function getLogEmails(): Collection
  1466.     {
  1467.         return $this->logEmails;
  1468.     }
  1469.     public function addLogEmail(LogEmail $logEmail): self
  1470.     {
  1471.         if (!$this->logEmails->contains($logEmail)) {
  1472.             $this->logEmails[] = $logEmail;
  1473.             $logEmail->setCompany($this);
  1474.         }
  1475.         return $this;
  1476.     }
  1477.     public function removeLogEmail(LogEmail $logEmail): self
  1478.     {
  1479.         if ($this->logEmails->removeElement($logEmail)) {
  1480.             // set the owning side to null (unless already changed)
  1481.             if ($logEmail->getCompany() === $this) {
  1482.                 $logEmail->setCompany(null);
  1483.             }
  1484.         }
  1485.         return $this;
  1486.     }
  1487.     /**
  1488.      * @return Collection|Association[]
  1489.      */
  1490.     public function getAssociations(): Collection
  1491.     {
  1492.         return $this->associations;
  1493.     }
  1494.     public function addAssociation(Association $association): self
  1495.     {
  1496.         if (!$this->associations->contains($association)) {
  1497.             $this->associations[] = $association;
  1498.         }
  1499.         return $this;
  1500.     }
  1501.     public function removeAssociation(Association $association): self
  1502.     {
  1503.         $this->associations->removeElement($association);
  1504.         return $this;
  1505.     }
  1506.     /**
  1507.      * @return Collection|Program[]
  1508.      */
  1509.     public function getPrograms(): Collection
  1510.     {
  1511.         return $this->programs;
  1512.     }
  1513.     public function addProgram(Program $program): self
  1514.     {
  1515.         if (!$this->programs->contains($program)) {
  1516.             $this->programs[] = $program;
  1517.             $program->setCompany($this);
  1518.         }
  1519.         return $this;
  1520.     }
  1521.     public function removeProgram(Program $program): self
  1522.     {
  1523.         if ($this->programs->removeElement($program)) {
  1524.             // set the owning side to null (unless already changed)
  1525.             if ($program->getCompany() === $this) {
  1526.                 $program->setCompany(null);
  1527.             }
  1528.         }
  1529.         return $this;
  1530.     }
  1531.     /**
  1532.      * @return Collection|Team[]
  1533.      */
  1534.     public function getTeams(): Collection
  1535.     {
  1536.         return $this->teams;
  1537.     }
  1538.     public function addTeam(Team $team): self
  1539.     {
  1540.         if (!$this->teams->contains($team)) {
  1541.             $this->teams[] = $team;
  1542.             $team->setCompany($this);
  1543.         }
  1544.         return $this;
  1545.     }
  1546.     public function removeTeam(Team $team): self
  1547.     {
  1548.         if ($this->teams->removeElement($team)) {
  1549.             // set the owning side to null (unless already changed)
  1550.             if ($team->getCompany() === $this) {
  1551.                 $team->setCompany(null);
  1552.             }
  1553.         }
  1554.         return $this;
  1555.     }
  1556.     /**
  1557.      * RĂ©cupère un array de team de type = "teamplay"
  1558.      * @return Team[]|null
  1559.      */
  1560.     public function getTeamplayTeams(): ?array
  1561.     {
  1562.         $teamplayTeams null;
  1563.         if (!empty($this->teams->toArray())) {
  1564.             $teamplayTeams = [];
  1565.             foreach ($this->teams->toArray() as $team) {
  1566.                 if ($team->isTeamplay()) $teamplayTeams[] = $team;
  1567.             }
  1568.         }
  1569.         return $teamplayTeams;
  1570.     }
  1571.     /**
  1572.      * @return Collection|Teamplay[]
  1573.      */
  1574.     public function getTeamplays(): Collection
  1575.     {
  1576.         return $this->teamplays;
  1577.     }
  1578.     public function addTeamplay(Teamplay $teamplay): self
  1579.     {
  1580.         if (!$this->teamplays->contains($teamplay)) {
  1581.             $this->teamplays[] = $teamplay;
  1582.             $teamplay->setCompany($this);
  1583.         }
  1584.         return $this;
  1585.     }
  1586.     public function removeTeamplay(Teamplay $teamplay): self
  1587.     {
  1588.         if ($this->teamplays->removeElement($teamplay)) {
  1589.             // set the owning side to null (unless already changed)
  1590.             if ($teamplay->getCompany() === $this) {
  1591.                 $teamplay->setCompany(null);
  1592.             }
  1593.         }
  1594.         return $this;
  1595.     }
  1596.     /**
  1597.      * @return Collection|TeamplayChallenge[]
  1598.      */
  1599.     public function getTeamplayChallenges(): Collection
  1600.     {
  1601.         return $this->teamplayChallenges;
  1602.     }
  1603.     public function addTeamplayChallenge(TeamplayChallenge $teamplayChallenge): self
  1604.     {
  1605.         if (!$this->teamplayChallenges->contains($teamplayChallenge)) {
  1606.             $this->teamplayChallenges[] = $teamplayChallenge;
  1607.             $teamplayChallenge->setCompany($this);
  1608.         }
  1609.         return $this;
  1610.     }
  1611.     public function removeTeamplayChallenge(TeamplayChallenge $teamplayChallenge): self
  1612.     {
  1613.         if ($this->teamplayChallenges->removeElement($teamplayChallenge)) {
  1614.             // set the owning side to null (unless already changed)
  1615.             if ($teamplayChallenge->getCompany() === $this) {
  1616.                 $teamplayChallenge->setCompany(null);
  1617.             }
  1618.         }
  1619.         return $this;
  1620.     }
  1621.     
  1622.     /**
  1623.      * @return Collection|TeamplayLog[]
  1624.      */
  1625.     public function getTeamplayLogs(): Collection
  1626.     {
  1627.         return $this->teamplayLogs;
  1628.     }
  1629.     public function addTeamplayLog(TeamplayLog $teamplayLog): self
  1630.     {
  1631.         if (!$this->teamplayLogs->contains($teamplayLog)) {
  1632.             $this->teamplayLogs[] = $teamplayLog;
  1633.             $teamplayLog->setCompany($this);
  1634.         }
  1635.         return $this;
  1636.     }
  1637.     public function removeTeamplayLog(TeamplayLog $teamplayLog): self
  1638.     {
  1639.         if ($this->teamplayLogs->removeElement($teamplayLog)) {
  1640.             // set the owning side to null (unless already changed)
  1641.             if ($teamplayLog->getCompany() === $this) {
  1642.                 $teamplayLog->setCompany(null);
  1643.             }
  1644.         }
  1645.         return $this;
  1646.     }
  1647.     /**
  1648.      * @return Collection|PedometerLog[]
  1649.      */
  1650.     public function getPedometerLogs(): Collection
  1651.     {
  1652.         return $this->pedometerLogs;
  1653.     }
  1654.     public function addPedometerLog(PedometerLog $pedometerLog): self
  1655.     {
  1656.         if (!$this->pedometerLogs->contains($pedometerLog)) {
  1657.             $this->pedometerLogs[] = $pedometerLog;
  1658.             $pedometerLog->setCompany($this);
  1659.         }
  1660.         return $this;
  1661.     }
  1662.     public function removePedometerLog(PedometerLog $pedometerLog): self
  1663.     {
  1664.         if ($this->pedometerLogs->removeElement($pedometerLog)) {
  1665.             // set the owning side to null (unless already changed)
  1666.             if ($pedometerLog->getCompany() === $this) {
  1667.                 $pedometerLog->setCompany(null);
  1668.             }
  1669.         }
  1670.         return $this;
  1671.     }
  1672.     /**
  1673.      * @return Collection|Log[]
  1674.      */
  1675.     public function getLogs(): Collection
  1676.     {
  1677.         return $this->logs;
  1678.     }
  1679.     public function addLog(Log $log): self
  1680.     {
  1681.         if (!$this->logs->contains($log)) {
  1682.             $this->logs[] = $log;
  1683.             $log->setCompany($this);
  1684.         }
  1685.         return $this;
  1686.     }
  1687.     public function removeLog(Log $log): self
  1688.     {
  1689.         if ($this->logs->removeElement($log)) {
  1690.             // set the owning side to null (unless already changed)
  1691.             if ($log->getCompany() === $this) {
  1692.                 $log->setCompany(null);
  1693.             }
  1694.         }
  1695.         return $this;
  1696.     }
  1697.     /**
  1698.      * @return Collection<int, UserNotification>
  1699.      */
  1700.     public function getUserNotifications(): Collection
  1701.     {
  1702.         return $this->userNotifications;
  1703.     }
  1704.     public function addUserNotification(UserNotification $userNotification): self
  1705.     {
  1706.         if (!$this->userNotifications->contains($userNotification)) {
  1707.             $this->userNotifications[] = $userNotification;
  1708.             $userNotification->setCompany($this);
  1709.         }
  1710.         return $this;
  1711.     }
  1712.     public function removeUserNotification(UserNotification $userNotification): self
  1713.     {
  1714.         if ($this->userNotifications->removeElement($userNotification)) {
  1715.             // set the owning side to null (unless already changed)
  1716.             if ($userNotification->getCompany() === $this) {
  1717.                 $userNotification->setCompany(null);
  1718.             }
  1719.         }
  1720.         return $this;
  1721.     }
  1722.     /**
  1723.      * @return Collection<int, Slide>
  1724.      */
  1725.     public function getSlides(): Collection
  1726.     {
  1727.         return $this->slides;
  1728.     }
  1729.     public function addSlide(Slide $slide): self
  1730.     {
  1731.         if (!$this->slides->contains($slide)) {
  1732.             $this->slides[] = $slide;
  1733.             $slide->setCompany($this);
  1734.         }
  1735.         return $this;
  1736.     }
  1737.     public function removeSlide(Slide $slide): self
  1738.     {
  1739.         if ($this->slides->removeElement($slide)) {
  1740.             // set the owning side to null (unless already changed)
  1741.             if ($slide->getCompany() === $this) {
  1742.                 $slide->setCompany(null);
  1743.             }
  1744.         }
  1745.         return $this;
  1746.     }
  1747.     /**
  1748.      * @return Collection|Award[]
  1749.      */
  1750.     public function getAwards(): Collection
  1751.     {
  1752.         return $this->awards;
  1753.     }
  1754.     public function addAward(Award $award): self
  1755.     {
  1756.         if (!$this->awards->contains($award)) {
  1757.             $this->awards[] = $award;
  1758.             $award->addCompany($this);
  1759.         }
  1760.         return $this;
  1761.     }
  1762.     public function removeAward(Award $award): self
  1763.     {
  1764.         if ($this->awards->removeElement($award)) {
  1765.             $award->removeCompany($this);
  1766.         }
  1767.         return $this;
  1768.     }
  1769.     /**
  1770.      * @Groups({"company:read", "compny:read:activeAward"})
  1771.      */
  1772.     public function getActiveAward()
  1773.     {
  1774.         $award null;
  1775.         $today = (new \DateTime("now"))->setTime(000);
  1776.         foreach ($this->awards->toArray() as $value) {
  1777.             if ($value->getActive() && $value->getDateStart() <= $today  && $value->getDateEnd() >= $today) {
  1778.                 $award $value;
  1779.             }
  1780.         }
  1781.         return $award;
  1782.     }
  1783.     /**
  1784.      * @return Collection<int, AwardConfig>
  1785.      */
  1786.     public function getAwardConfigs(): Collection
  1787.     {
  1788.         return $this->awardConfigs;
  1789.     }
  1790.     public function addAwardConfig(AwardConfig $awardConfig): self
  1791.     {
  1792.         if (!$this->awardConfigs->contains($awardConfig)) {
  1793.             $this->awardConfigs[] = $awardConfig;
  1794.             $awardConfig->setCompany($this);
  1795.         }
  1796.         return $this;
  1797.     }
  1798.     public function removeAwardConfig(AwardConfig $awardConfig): self
  1799.     {
  1800.         if ($this->awardConfigs->removeElement($awardConfig)) {
  1801.             // set the owning side to null (unless already changed)
  1802.             if ($awardConfig->getCompany() === $this) {
  1803.                 $awardConfig->setCompany(null);
  1804.             }
  1805.         }
  1806.         return $this;
  1807.     }
  1808.     
  1809.     public function getClientsCount(): ?int
  1810.     {
  1811.         return $this->clientsCount;
  1812.     }
  1813.     public function setClientsCount(int $clientsCount): self
  1814.     {
  1815.         $this->clientsCount $clientsCount;
  1816.         return $this;
  1817.     }
  1818.     public function getTvCompany(): ?TvCompany
  1819.     {
  1820.         return $this->tvCompany;
  1821.     }
  1822.     public function setTvCompany(?TvCompany $tvCompany): self
  1823.     {
  1824.         $this->tvCompany $tvCompany;
  1825.         return $this;
  1826.     }
  1827.     public function isLive(): ?bool
  1828.     {
  1829.         return $this->live;
  1830.     }
  1831.     public function setLive(bool $isLive): self
  1832.     {
  1833.         $this->live $isLive;
  1834.         $this->getUser()->setLive($isLive);
  1835.         $this->getUser()->setUpdatedAt(new \DateTime("now"));
  1836.         // if(!$this->getClients()->isEmpty()) {
  1837.         //     foreach($this->getClients()->toArray() as  $client) {
  1838.         //         if($client instanceof Client && $client->getUser() instanceof User) {
  1839.         //             $user = $client->getUser();
  1840.         //             $user->setLive($isLive);
  1841.         //             $user->setUpdatedAt(new \DateTime("now"));
  1842.         //         }
  1843.         //     }
  1844.         // }
  1845.         return $this;
  1846.     }
  1847.     public function isTv(): ?bool
  1848.     {
  1849.         return $this->tv;
  1850.     }
  1851.     public function setTv(bool $isTv): self
  1852.     {
  1853.         $this->tv $isTv;
  1854.         $this->getUser()->setTv($isTv);
  1855.         $this->getUser()->setUpdatedAt(new \DateTime("now"));
  1856.         // if(!$this->getClients()->isEmpty()) {
  1857.         //     foreach($this->getClients()->toArray() as  $client) {
  1858.         //         if($client instanceof Client && $client->getUser() instanceof User) {
  1859.         //             $user = $client->getUser();
  1860.         //             $user->setTv($isTv);
  1861.         //             $user->setUpdatedAt(new \DateTime("now"));
  1862.         //         }
  1863.         //     }
  1864.         // }
  1865.         return $this;
  1866.     }
  1867.     /**
  1868.      *  VĂ©rifie si les associations sont actives
  1869.      */
  1870.     public function isActiveAssociation(): bool
  1871.     {
  1872.         $isActiveAssociation false;
  1873.         
  1874.         if(!empty($this->getAssociations()->toArray())) {
  1875.             foreach ($this->getAssociations()->toArray() as $association) {
  1876.                 if($association->getActive() == 1) {
  1877.                     $isActiveAssociation true;
  1878.                     break;
  1879.                 }
  1880.             }
  1881.         }
  1882.         return $isActiveAssociation;
  1883.     }
  1884.     /**
  1885.      * Indicates if a user is restricted according to general company restrictions
  1886.      *
  1887.      * @param \DateTime $time
  1888.      * @return bool
  1889.      */
  1890.     public function isRestricted(\DateTime $time): bool
  1891.     {
  1892.         foreach ($this->restrictions as $restriction) {
  1893.             if ($restriction instanceof Restriction && $restriction->isRestricted($time)) {
  1894.                 return true;
  1895.             }
  1896.         }
  1897.         return false;
  1898.     }
  1899.     /**
  1900.      * Gets the start of the next restriction on a given interval
  1901.      * @param \DateTime $start
  1902.      * @param \DateTime $end
  1903.      * @return \DateTime|null
  1904.      */
  1905.     public function getNextRestriction(\DateTime $start\DateTime $end): ?\DateTime
  1906.     {
  1907.         foreach ($this->restrictions as $restriction) {
  1908.             if ($restriction instanceof Restriction) {
  1909.                 $startRestriction $restriction->getStart($start);
  1910.                 if ($startRestriction <= $end) {
  1911.                     return $startRestriction;
  1912.                 }
  1913.             }
  1914.         }
  1915.         return null;
  1916.     }
  1917.     /**
  1918.      * Gets the end of a restriction
  1919.      * @return string
  1920.      */
  1921.     public function getEndRestriction(\DateTime $day): string
  1922.     {
  1923.         foreach ($this->restrictions as $restriction) {
  1924.             if (
  1925.                 $restriction instanceof Restriction && $restriction->isRestricted($day)
  1926.                 && $restriction->getCode() == Restriction::WEEKLY
  1927.             ) {
  1928.                 return $restriction->getEnd($day)->format('H:i');
  1929.             }
  1930.         }
  1931.         return '';
  1932.     }
  1933.     /**
  1934.      * Gets the end of a restriction
  1935.      * @return string
  1936.      */
  1937.     public function getStartRestriction(\DateTime $day): string
  1938.     {
  1939.         foreach ($this->restrictions as $restriction) {
  1940.             if (
  1941.                 $restriction instanceof Restriction && $restriction->isRestricted($day)
  1942.                 && $restriction->getCode() == Restriction::WEEKLY
  1943.             ) {
  1944.                 return $restriction->getStart($day)->format('H:i');
  1945.             }
  1946.         }
  1947.         return '';
  1948.     }
  1949.     public function getImageUrl(): ?string
  1950.     {
  1951.         return $this->imageUrl;
  1952.     }
  1953.     public function setImageUrl(string $imageUrl): self
  1954.     {
  1955.         $this->imageUrl $imageUrl;
  1956.         return $this;
  1957.     }
  1958.     public function getConsultLink(): ?string
  1959.     {
  1960.         return $this->consultLink;
  1961.     }
  1962.     public function setConsultLink(?string $consultLink): self
  1963.     {
  1964.         $this->consultLink $consultLink;
  1965.         
  1966.         return $this;
  1967.     }
  1968. }