src/Entity/TeamplayChallenge.php line 88

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\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  7. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
  8. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  9. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  10. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\ExistsFilter;
  11. use ApiPlatform\Core\Serializer\Filter\GroupFilter;
  12. use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
  13. use App\Repository\TeamplayChallengeRepository;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use Doctrine\Common\Collections\Collection;
  16. use Doctrine\ORM\Mapping as ORM;
  17. use Gedmo\Mapping\Annotation as Gedmo;
  18. use Symfony\Component\HttpFoundation\File\UploadedFile;
  19. use Symfony\Component\Serializer\Annotation\Groups;
  20. use Symfony\Component\Validator\Constraints as Assert;
  21. use App\Entity\KinestexExercise;
  22. /**
  23.  * @ApiResource(
  24.  *      normalizationContext={
  25.  *          "groups"={"teamplay_challenge:read"}
  26.  *      },
  27.  *      denormalizationContext={
  28.  *          "groups"={"teamplay_challenge:write"}
  29.  *      },
  30.  *      itemOperations={
  31.  *          "get"={
  32.  *              "security"="is_granted('ROLE_USER')"
  33.  *          },
  34.  *          "patch"={
  35.  *              "security"="is_granted('ROLE_ADMIN')"
  36.  *          },
  37.  *          "delete"={
  38.  *              "security"="is_granted('ROLE_ADMIN')"
  39.  *          }
  40.  *      },
  41.  *      collectionOperations={
  42.  *          "get"={
  43.  *              "security"="is_granted('ROLE_USER')"
  44.  *          }, 
  45.  *          "get_client_teamplay_collected"={
  46.  *              "security"="is_granted('ROLE_CLIENT')",
  47.  *              "method"="GET",
  48.  *              "description"="Get completed TeamplayChallenge by a Client",
  49.  *              "controller"="App\Controller\Api\TeamplayChallengeController::getClientTeamplayChallengeCompleted"
  50.  *          }, 
  51.  *          "post"={
  52.  *              "security"="is_granted('ROLE_ADMIN')"
  53.  *          },
  54.  *          "post_update"={
  55.  *              "security"="is_granted('ROLE_ADMIN')",
  56.  *              "path"="/teamplay_challenges/{id}",
  57.  *              "description"="Update a TeamplayChallenge with method POST (using content-type: 'multipart')",
  58.  *              "method"="POST",
  59.  *              "controller"="App\Controller\Api\TeamplayChallengeController::update"
  60.  *          }
  61.  *      }
  62.  * )
  63.  * @ORM\Entity(repositoryClass=TeamplayChallengeRepository::class)
  64.  * @ApiFilter(SearchFilter::class, 
  65.  *      strategy="exact", 
  66.  *      properties={"active", "teamplay.id", "name": "partial", "type", "company.id", "isTemplate"}
  67.  * )
  68.  * @ApiFilter(ExistsFilter::class, properties={"teamplay", "company", "video", "survey", "type"})
  69.  * @ApiFilter(BooleanFilter::class, properties={"active", "isTemplate"})
  70.  * @ApiFilter(DateFilter::class, properties={"dateStart", "dateEnd"})
  71.  * @ApiFilter(OrderFilter::class)
  72.  * @ApiFilter(GroupFilter::class, 
  73.  *      arguments={
  74.  *          "parameterName": "groups", 
  75.  *          "overrideDefaultGroups": true
  76.  *      }
  77.  * )
  78.  * @ApiFilter(PropertyFilter::class, 
  79.  *      arguments={
  80.  *          "parameterName"="fields", 
  81.  *          "overrideDefaultProperties"=true
  82.  *     }
  83.  * )
  84.  */
  85. class TeamplayChallenge
  86. {
  87.     const TYPE_STEP = "step";
  88.     const TYPE_BIKE = "bike";
  89.     const TYPE_RUN = "run";
  90.     const TYPE_RECURRENT_STEP = "recurrent_step";
  91.     const TYPE_RECURRENT_BIKE = "recurrent_bike";
  92.     const TYPE_RECURRENT_RUN = "recurrent_run";
  93.     const TYPE_RECURRENT_RANKING_AWARD = "recurrent_ranking_award";
  94.     const TYPE_VIDEO_PHYSICAL = "video_physical";
  95.     const TYPE_VIDEO_INTERVIEW = "video_interview";
  96.     const TYPE_QUIZ = "quiz";
  97.     const TYPE_KINESTEX = "kinestex";
  98.     const TYPE_RECURRENT_KINESTEX = 'recurrent_kinestex';
  99.     const TYPE_DAILY_REWARD = "daily_reward";
  100.     const TYPES = [
  101.         self::TYPE_STEP,
  102.         self::TYPE_BIKE,
  103.         self::TYPE_RUN,
  104.         self::TYPE_RECURRENT_STEP,
  105.         self::TYPE_RECURRENT_BIKE,
  106.         self::TYPE_RECURRENT_RUN,
  107.         self::TYPE_RECURRENT_RANKING_AWARD,
  108.         self::TYPE_VIDEO_PHYSICAL,
  109.         self::TYPE_VIDEO_INTERVIEW,
  110.         self::TYPE_QUIZ,
  111.         self::TYPE_KINESTEX,
  112.         self::TYPE_DAILY_REWARD,
  113.     ];
  114.     const STATUS_IN_PROGRESS = "in_progress";
  115.     const STATUS_IN_COMING = "in_coming";
  116.     const STATUS_PASSED = "passed";
  117.     const STATUS = [
  118.         self::STATUS_IN_PROGRESS,
  119.         self::STATUS_IN_COMING,
  120.         self::STATUS_PASSED
  121.     ];
  122.     const EVERY_TYPE_HOUR = "hour";
  123.     const EVERY_TYPE_DAY = "day";
  124.     const EVERY_TYPE_WEEK = "week";
  125.     const EVERY_TYPE_MONTH = "month";
  126.     const EVERY_TYPE_YEAR = "year";
  127.     const EVERY_DATE_TYPES = [
  128.         self::EVERY_TYPE_HOUR,
  129.         self::EVERY_TYPE_DAY,
  130.         self::EVERY_TYPE_WEEK,
  131.         self::EVERY_TYPE_MONTH,
  132.         self::EVERY_TYPE_YEAR,
  133.     ];
  134.     /**
  135.      * @ORM\Id
  136.      * @ORM\GeneratedValue
  137.      * @ORM\Column(type="integer")
  138.      * @Groups({"teamplay_challenge:read:id", "teamplay_challenge:read", "teamplay_challenge_simple", "teamplay:read", "challenge_form"})
  139.      */
  140.     private $id;
  141.     /**
  142.      * @ORM\Column(type="string", length=255, nullable=true)
  143.      * @Groups({"teamplay_challenge:read:name", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read", "challenge_form"})
  144.      */
  145.     private $name;
  146.     /**
  147.      * @ORM\Column(type="text", nullable=true)
  148.      * @Groups({"teamplay_challenge:read:description", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  149.      */
  150.     private $description;
  151.     /**
  152.      * @ORM\Column(type="string", length=255, nullable=true)
  153.      * @Assert\Choice(choices=self::TYPES)
  154.      * @Groups({"teamplay_challenge:read:type", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  155.      */
  156.     private $type;
  157.     /**
  158.      * @ORM\ManyToOne(targetEntity=MediaObject::class)
  159.      * @Groups({"teamplay_challenge:read:picture", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  160.      */
  161.     private $picture;
  162.     /**
  163.      * @ORM\Column(type="integer", nullable=true)
  164.      * @Groups({"teamplay_challenge:read:duration", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  165.      */
  166.     private $duration;
  167.     /**
  168.      * @ORM\Column(type="integer", nullable=true)
  169.      * @Groups({"teamplay_challenge:read:pointAmount", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  170.      */
  171.     private $pointAmount;
  172.     /**
  173.      * @ORM\Column(type="integer", nullable=true)
  174.      * @Groups({"teamplay_challenge:read:stepAmount", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  175.      */
  176.     private $stepAmount;
  177.     /**
  178.      * @ORM\Column(type="integer", nullable=true)
  179.      * @Groups({"teamplay_challenge:read:dayStart", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  180.      */
  181.     private $dayStart;
  182.     /**
  183.      * @ORM\Column(type="integer", nullable=true)
  184.      * @Groups({"teamplay_challenge:read:dayEnd", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  185.      */
  186.     private $dayEnd;
  187.     /**
  188.      * @ORM\Column(type="datetime", nullable=true)
  189.      * @Groups({"teamplay_challenge:read:dateStart", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  190.      */
  191.     private $dateStart;
  192.     /**
  193.      * @ORM\Column(type="datetime", nullable=true)
  194.      * @Groups({"teamplay_challenge:read:dateEnd", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  195.      */
  196.     private $dateEnd;
  197.     /**
  198.      * @ORM\ManyToOne(targetEntity=Video::class, inversedBy="teamplayChallenges")
  199.      * @Groups({"teamplay_challenge:read:video", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  200.      */
  201.     private $video;
  202.     /**
  203.      * @ORM\ManyToOne(targetEntity=Survey::class, inversedBy="teamplayChallenges", cascade={"persist", "refresh", "remove"})
  204.      * @Groups({"teamplay_challenge:read:survey", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  205.      */
  206.     private $survey;
  207.     /**
  208.      * @ORM\Column(type="boolean", nullable=true, options={"default": "1"})
  209.      * @Groups({"teamplay_challenge:read:isTemplate", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  210.      */
  211.     private $isTemplate = true;
  212.     /**
  213.      * @ORM\Column(type="integer", nullable=true)
  214.      * @Groups({"teamplay_challenge:read:awardAmount", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  215.      */
  216.     private $awardAmount;
  217.     /**
  218.      * @ORM\Column(type="boolean", options={"default": "0"})
  219.      * @Groups({"teamplay_challenge:read:isMultipleWinnable", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  220.      */
  221.     private $isMultipleWinnable = false;
  222.     /**
  223.      * @ORM\Column(type="integer", nullable=true)
  224.      * @Groups({"teamplay_challenge:read:everyInt", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  225.      */
  226.     private $everyInt;
  227.     /**
  228.      * @ORM\Column(type="string", length=255, nullable=true)
  229.      * @Groups({"teamplay_challenge:read:everyDateType", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  230.      */
  231.     private $everyDateType;
  232.     /**
  233.      * @ORM\ManyToOne(targetEntity=TvCompany::class, inversedBy="teamplayChallenges")
  234.      */
  235.     private $tvCompany;
  236.     /**
  237.      * @ORM\ManyToOne(targetEntity=Company::class, inversedBy="teamplayChallenges")
  238.      * @Groups({"teamplay_challenge:read:company", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  239.      */
  240.     private $company;
  241.     /**
  242.      * @ORM\Column(type="boolean", nullable=true, options={"default": "1"})
  243.      * @Groups({"teamplay_challenge:read:active", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  244.      */
  245.     private $active = true;
  246.     /**
  247.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  248.      * @Gedmo\Timestampable(on="create")
  249.      * @Groups({"teamplay_challenge:read:createdAt", "teamplay_challenge:read", "teamplay_challenge_simple"})
  250.      */
  251.     private $createdAt;
  252.     /**
  253.      * @ORM\Column(type="datetime", nullable=true)
  254.      * @Gedmo\Timestampable(on="update")
  255.      * @Groups({"teamplay_challenge:read:updatedAt", "teamplay_challenge:read", "teamplay_challenge_simple"})
  256.      */
  257.     private $updatedAt;
  258.     /**
  259.      * @ORM\ManyToOne(targetEntity=Teamplay::class, inversedBy="challenges", cascade={"refresh"})
  260.      * @Groups({"teamplay_challenge:read:teamplay", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple"})
  261.      */
  262.     private $teamplay;
  263.     /**
  264.      * @ORM\OneToMany(targetEntity=TeamplayLog::class, mappedBy="teamplayChallenge", cascade={"persist", "refresh", "remove"})
  265.      */
  266.     private $teamplayLogs;
  267.     /**
  268.      * Champ Custom (PostLoad)
  269.      * Permet de savoir si le TeamplayChallenge a été complété par le Client connecté
  270.      * @var ?bool
  271.      * @Groups({"teamplay_challenge:read:isCompleted", "teamplay_challenge:read"})
  272.      */
  273.     public $isCompleted = null;
  274.     /**
  275.      * Champ Custom (PostLoad)
  276.      * Permet de savoir si le Client connecté a récupéré les points du TeamplayChallenge
  277.      * @var ?bool
  278.      * @Groups({"teamplay_challenge:read:isCollected", "teamplay_challenge:read"})
  279.      */
  280.     public $isCollected = null;
  281.     /**
  282.      * Champ Custom (PostLoad)
  283.      * Nombre de pas effectués par le Client connecté durant ce challenge
  284.      * @var ?int
  285.      * @Groups({"teamplay_challenge:read:userStepsAmount", "teamplay_challenge:read"})
  286.      */
  287.     public $userStepsAmount = null;
  288.     /**
  289.      * Distance requise, EN KM (saisie telle quelle au back-office). Pour comparer à une distance
  290.      * parcourue (en mètres), utiliser getBikeAmountMeters() : seule conversion autorisée (#3369)
  291.      * @ORM\Column(type="integer", nullable=true)
  292.      * @Groups({"teamplay_challenge:read:bikeAmount", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  293.      */
  294.     private $bikeAmount;
  295.     /**
  296.      * Champ Custom (PostLoad)
  297.      * Nombre de mètres parcourus à vélo par le Client connecté durant ce challenge (avec décimales)
  298.      * @var ?float
  299.      * @Groups({"teamplay_challenge:read:userBikeAmount", "teamplay_challenge:read"})
  300.      */
  301.     public $userBikeAmount = null;
  302.     /**
  303.      * Distance requise, EN KM (saisie telle quelle au back-office). Pour comparer à une distance
  304.      * parcourue (en mètres), utiliser getRunAmountMeters() : seule conversion autorisée (#3369)
  305.      * @ORM\Column(type="integer", nullable=true)
  306.      * @Groups({"teamplay_challenge:read:runAmount", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  307.      */
  308.     private $runAmount;
  309.     /**
  310.      * Champ Custom (PostLoad)
  311.      * Nombre de mètres parcourus en course à pied par le Client connecté durant ce challenge (avec décimales)
  312.      * @var ?float
  313.      * @Groups({"teamplay_challenge:read:userRunAmount", "teamplay_challenge:read"})
  314.      */
  315.     public $userRunAmount = null;
  316.     /**
  317.      * Score KinesteX requis pour valider le challenge (pourcentage de 0 à 100)
  318.      * @ORM\Column(type="integer", nullable=true)
  319.      * @Groups({"teamplay_challenge:read:kinestexAmount", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  320.      */
  321.     private $kinestexAmount;
  322.     /**
  323.      * Champ Custom (PostLoad)
  324.      * Score de précision KinesteX obtenu par le Client connecté durant ce challenge
  325.      * @var ?float
  326.      * @Groups({"teamplay_challenge:read:userKinestexAmount", "teamplay_challenge:read"})
  327.      */
  328.     public $userKinestexAmount = null;
  329.     /**
  330.      * Champ Custom (PostLoad)
  331.      * Nombre total de répétitions effectuées par le Client durant ce challenge KinesteX
  332.      * @var ?int
  333.      * @Groups({"teamplay_challenge:read:userKinestexReps", "teamplay_challenge:read"})
  334.      */
  335.     public $userKinestexReps = null;
  336.     /**
  337.      * Champ Custom (PostLoad)  
  338.      * Durée totale en secondes effectuée par le Client durant ce challenge KinesteX
  339.      * @var ?int
  340.      * @Groups({"teamplay_challenge:read:userKinestexDuration", "teamplay_challenge:read"})
  341.      */
  342.     public $userKinestexDuration = null;
  343.     /**
  344.      * Champ Custom (PostLoad)
  345.      * Nombre total de sessions KinesteX effectuées par le Client durant ce challenge
  346.      * @var ?int
  347.      * @Groups({"teamplay_challenge:read:userKinestexSessions", "teamplay_challenge:read"})
  348.      */
  349.     public $userKinestexSessions = null;
  350.     /**
  351.      * Champ Custom (PostLoad)
  352.      * Nombre de sessions KinesteX complétées (80%+) par le Client durant ce challenge
  353.      * @var ?int
  354.      * @Groups({"teamplay_challenge:read:userKinestexCompletedSessions", "teamplay_challenge:read"})
  355.      */
  356.     public $userKinestexCompletedSessions = null;
  357.     /**
  358.      * Champ Custom (PostLoad)
  359.      * Pourcentage moyen de complétion des sessions KinesteX du Client durant ce challenge
  360.      * @var ?float
  361.      * @Groups({"teamplay_challenge:read:userKinestexAvgAccuracy", "teamplay_challenge:read"})
  362.      */
  363.     public $userKinestexAvgAccuracy = null;
  364.     /**
  365.      * Points attribués pour un score KinesteX entre 10% et 40%
  366.      * @ORM\Column(type="integer", nullable=true)
  367.      * @Groups({"teamplay_challenge:read:kinestexPointsLow", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  368.      */
  369.     private $kinestexPointsLow;
  370.     /**
  371.      * Points attribués pour un score KinesteX entre 40% et 70%
  372.      * @ORM\Column(type="integer", nullable=true)
  373.      * @Groups({"teamplay_challenge:read:kinestexPointsMedium", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  374.      */
  375.     private $kinestexPointsMedium;
  376.     /**
  377.      * Points attribués pour un score KinesteX entre 70% et 100%
  378.      * @ORM\Column(type="integer", nullable=true)
  379.      * @Groups({"teamplay_challenge:read:kinestexPointsHigh", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  380.      */
  381.     private $kinestexPointsHigh;
  382.     /**
  383.      * Exercice KinesteX associé
  384.      * @ORM\ManyToOne(targetEntity=KinestexExercise::class)
  385.      * @Groups({"teamplay_challenge:read", "teamplay_challenge:write"})
  386.      */
  387.     private $kinestexExercise;
  388.     /**
  389.      * Objectif de répétitions pour l'exercice KinesteX (si type repetition)
  390.      * @ORM\Column(type="integer", nullable=true)
  391.      * @Groups({"teamplay_challenge:read", "teamplay_challenge:write"})
  392.      */
  393.     private $kinestexRepetitions;
  394.     /**
  395.      * Objectif de durée en secondes pour l'exercice KinesteX (si type duration)
  396.      * @ORM\Column(type="integer", nullable=true)
  397.      * @Groups({"teamplay_challenge:read", "teamplay_challenge:write"})
  398.      */
  399.     private $kinestexDuration;
  400.     /**
  401.      * Points attribués pour la récompense quotidienne
  402.      * @ORM\Column(type="integer", nullable=true)
  403.      * @Groups({"teamplay_challenge:read:dailyRewardPoints", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  404.      */
  405.     private $dailyRewardPoints;
  406.     /**
  407.      * Heure de base pour l'envoi des notifications (format HH:MM)
  408.      * @ORM\Column(type="string", length=5, nullable=true)
  409.      * @Groups({"teamplay_challenge:read:notificationBaseTime", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  410.      */
  411.     private $notificationBaseTime;
  412.     /**
  413.      * Décalage maximum en minutes pour étaler les notifications
  414.      * @ORM\Column(type="integer", nullable=true, options={"default": "120"})
  415.      * @Groups({"teamplay_challenge:read:notificationMaxOffset", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  416.      */
  417.     private $notificationMaxOffset = 120;
  418.     public function __construct()
  419.     {
  420.         $this->teamplayLogs = new ArrayCollection();
  421.     }
  422.     public function getId(): ?int
  423.     {
  424.         return $this->id;
  425.     }
  426.     public function setId(?int $id): self
  427.     {
  428.         $this->id = $id;
  429.         return $this;
  430.     }
  431.     public function getName(): ?string
  432.     {
  433.         return $this->name;
  434.     }
  435.     public function setName(?string $name): self
  436.     {
  437.         $this->name = $name;
  438.         return $this;
  439.     }
  440.     public function getDescription(): ?string
  441.     {
  442.         return $this->description;
  443.     }
  444.     public function setDescription(?string $description): self
  445.     {
  446.         $this->description = $description;
  447.         return $this;
  448.     }
  449.     public function getType(): ?string
  450.     {
  451.         return $this->type;
  452.     }
  453.     public function setType(?string $type): self
  454.     {
  455.         $this->type = $type;
  456.         return $this;
  457.     }
  458.     public function getPicture(): ?MediaObject
  459.     {
  460.         return $this->picture;
  461.     }
  462.     public function setPicture(?MediaObject $picture): self
  463.     {
  464.         $this->picture = $picture;
  465.         return $this;
  466.     }
  467.     /**
  468.      * @Groups({"teamplay_challenge:write"})
  469.      */
  470.     public function setPictureFile($file = null): self
  471.     {
  472.         if ($file instanceof UploadedFile) {
  473.             $picture = empty($this->picture) ? new MediaObject : $this->picture;
  474.             $picture->setFile($file);
  475.             $this->setPicture($picture);
  476.         }
  477.         return $this;
  478.     }
  479.     public function getDuration(): ?int
  480.     {
  481.         return $this->duration;
  482.     }
  483.     public function setDuration(?int $duration): self
  484.     {
  485.         $this->duration = $duration;
  486.         return $this;
  487.     }
  488.     public function getPointAmount(): ?int
  489.     {
  490.         return $this->pointAmount;
  491.     }
  492.     public function setPointAmount(?int $pointAmount): self
  493.     {
  494.         $this->pointAmount = $pointAmount;
  495.         return $this;
  496.     }
  497.     public function getStepAmount(): ?int
  498.     {
  499.         return $this->stepAmount;
  500.     }
  501.     public function setStepAmount(?int $stepAmount): self
  502.     {
  503.         $this->stepAmount = $stepAmount;
  504.         return $this;
  505.     }
  506.     public function getDayStart(): ?int
  507.     {
  508.         return $this->dayStart;
  509.     }
  510.     public function setDayStart(?int $dayStart): self
  511.     {
  512.         $this->dayStart = $dayStart;
  513.         return $this;
  514.     }
  515.     public function getDayEnd(): ?int
  516.     {
  517.         return $this->dayEnd;
  518.     }
  519.     public function setDayEnd(?int $dayEnd): self
  520.     {
  521.         $this->dayEnd = $dayEnd;
  522.         return $this;
  523.     }
  524.     public function getDateStart(): ?\DateTimeInterface
  525.     {
  526.         return $this->dateStart;
  527.     }
  528.     public function setDateStart(?\DateTimeInterface $dateStart = null): self
  529.     {
  530.         $this->dateStart = $dateStart;
  531.         return $this;
  532.     }
  533.     public function getDateEnd(): ?\DateTimeInterface
  534.     {
  535.         return $this->dateEnd;
  536.     }
  537.     public function setDateEnd(?\DateTimeInterface $dateEnd): self
  538.     {
  539.         $this->dateEnd = $dateEnd;
  540.         return $this;
  541.     }
  542.     public function getVideo(): ?Video
  543.     {
  544.         return $this->video;
  545.     }
  546.     public function setVideo(?Video $video): self
  547.     {
  548.         $this->video = $video;
  549.         return $this;
  550.     }
  551.     public function getSurvey(): ?Survey
  552.     {
  553.         return $this->survey;
  554.     }
  555.     public function setSurvey(?Survey $survey): self
  556.     {
  557.         $this->survey = $survey;
  558.         return $this;
  559.     }
  560.     public function isTemplate(): bool
  561.     {
  562.         return $this->getIsTemplate();
  563.     }
  564.     public function getIsTemplate(): ?bool
  565.     {
  566.         return $this->isTemplate;
  567.     }
  568.     public function setIsTemplate(?bool $isTemplate): self
  569.     {
  570.         $this->isTemplate = $isTemplate;
  571.         return $this;
  572.     }
  573.     public function getTvCompany(): ?TvCompany
  574.     {
  575.         return $this->tvCompany;
  576.     }
  577.     public function setTvCompany(?TvCompany $tvCompany): self
  578.     {
  579.         $this->tvCompany = $tvCompany;
  580.         return $this;
  581.     }
  582.     public function getCompany(): ?Company
  583.     {
  584.         return $this->company;
  585.     }
  586.     public function setCompany(?Company $company): self
  587.     {
  588.         $this->company = $company;
  589.         return $this;
  590.     }
  591.     public function getTeamplay(): ?Teamplay
  592.     {
  593.         return $this->teamplay;
  594.     }
  595.     public function setTeamplay(?Teamplay $teamplay): self
  596.     {
  597.         $this->teamplay = $teamplay;
  598.         return $this;
  599.     }
  600.     public function getActive(): ?bool
  601.     {
  602.         return $this->active;
  603.     }
  604.     public function setActive(?bool $active): self
  605.     {
  606.         $this->active = $active;
  607.         return $this;
  608.     }
  609.     public function getCreatedAt(): ?\DateTimeInterface
  610.     {
  611.         return $this->createdAt;
  612.     }
  613.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  614.     {
  615.         $this->createdAt = $createdAt;
  616.         return $this;
  617.     }
  618.     public function getUpdatedAt(): ?\DateTimeInterface
  619.     {
  620.         return $this->updatedAt;
  621.     }
  622.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  623.     {
  624.         $this->updatedAt = $updatedAt;
  625.         return $this;
  626.     }
  627.     /**
  628.      * @Groups({"teamplay_challenge:read:isInProgress", "teamplay_challenge:read", "teamplay_challenge_simple"})
  629.      */
  630.     public function isInProgress(): ?bool
  631.     {
  632.         $today = new \DateTime("now");
  633.         if ($this->getDateStart() <= $today && $this->getDateEnd() > $today) {
  634.             return true;
  635.         }
  636.         return false;
  637.     }
  638.     /**
  639.      * @Groups({"teamplay_challenge:read:isInComing", "teamplay_challenge:read", "teamplay_challenge_simple"})
  640.      */
  641.     public function isInComing(): ?bool
  642.     {
  643.         $today = new \DateTime("now");
  644.         if ($this->getDateStart() > $today) {
  645.             return true;
  646.         }
  647.         return false;
  648.     }
  649.     /**
  650.      * @Groups({"teamplay_challenge:read:isPassed", "teamplay_challenge:read", "teamplay_challenge_simple"})
  651.      */
  652.     public function isPassed(): ?bool
  653.     {
  654.         $today = new \DateTime("now");
  655.         if ($this->getDateEnd() < $today) {
  656.             return true;
  657.         }
  658.         return false;
  659.     }
  660.     /**
  661.      * @return Collection|TeamplayLog[]
  662.      */
  663.     public function getTeamplayLogs(): Collection
  664.     {
  665.         return $this->teamplayLogs;
  666.     }
  667.     public function addTeamplayLog(TeamplayLog $teamplayLog): self
  668.     {
  669.         if (!$this->teamplayLogs->contains($teamplayLog)) {
  670.             $this->teamplayLogs[] = $teamplayLog;
  671.             $teamplayLog->setTeamplayChallenge($this);
  672.         }
  673.         return $this;
  674.     }
  675.     public function removeTeamplayLog(TeamplayLog $teamplayLog): self
  676.     {
  677.         if ($this->teamplayLogs->removeElement($teamplayLog)) {
  678.             if ($teamplayLog->getTeamplayChallenge() === $this) {
  679.                 $teamplayLog->setTeamplayChallenge(null);
  680.             }
  681.         }
  682.         return $this;
  683.     }
  684.     public function getAwardAmount(): ?int
  685.     {
  686.         return $this->awardAmount;
  687.     }
  688.     public function setAwardAmount(?int $awardAmount): self
  689.     {
  690.         $this->awardAmount = $awardAmount;
  691.         return $this;
  692.     }
  693.     public function getIsMultipleWinnable(): ?bool
  694.     {
  695.         return $this->isMultipleWinnable;
  696.     }
  697.     public function setIsMultipleWinnable(bool $isMultipleWinnable): self
  698.     {
  699.         $this->isMultipleWinnable = $isMultipleWinnable;
  700.         return $this;
  701.     }
  702.     public function getEveryInt(): ?int
  703.     {
  704.         return $this->everyInt;
  705.     }
  706.     public function setEveryInt(?int $everyInt): self
  707.     {
  708.         $this->everyInt = $everyInt;
  709.         return $this;
  710.     }
  711.     public function getEveryDateType(): ?string
  712.     {
  713.         return $this->everyDateType;
  714.     }
  715.     public function setEveryDateType(?string $everyDateType): self
  716.     {
  717.         $this->everyDateType = $everyDateType;
  718.         return $this;
  719.     }
  720.     public function getBikeAmount(): ?int
  721.     {
  722.         return $this->bikeAmount;
  723.     }
  724.     public function setBikeAmount(?int $bikeAmount): self
  725.     {
  726.         $this->bikeAmount = $bikeAmount;
  727.         return $this;
  728.     }
  729.     public function getRunAmount(): ?int
  730.     {
  731.         return $this->runAmount;
  732.     }
  733.     public function setRunAmount(?int $runAmount): self
  734.     {
  735.         $this->runAmount = $runAmount;
  736.         return $this;
  737.     }
  738.     /**
  739.      * Seuil vélo en mètres (#3369) : bikeAmount est en km, les distances parcourues en mètres.
  740.      * Seul endroit où le seuil est converti.
  741.      * @Groups({"teamplay_challenge:read:bikeAmount", "teamplay_challenge:read", "teamplay_challenge_simple", "teamplay:read"})
  742.      */
  743.     public function getBikeAmountMeters(): ?int
  744.     {
  745.         return $this->bikeAmount === null ? null : $this->bikeAmount * 1000;
  746.     }
  747.     /**
  748.      * Seuil course en mètres (#3369) : runAmount est en km, les distances parcourues en mètres.
  749.      * Seul endroit où le seuil est converti.
  750.      * @Groups({"teamplay_challenge:read:runAmount", "teamplay_challenge:read", "teamplay_challenge_simple", "teamplay:read"})
  751.      */
  752.     public function getRunAmountMeters(): ?int
  753.     {
  754.         return $this->runAmount === null ? null : $this->runAmount * 1000;
  755.     }
  756.     public function getKinestexAmount(): ?int
  757.     {
  758.         return $this->kinestexAmount;
  759.     }
  760.     public function setKinestexAmount(?int $kinestexAmount): self
  761.     {
  762.         $this->kinestexAmount = $kinestexAmount;
  763.         return $this;
  764.     }
  765.     public function getKinestexPointsLow(): ?int
  766.     {
  767.         return $this->kinestexPointsLow;
  768.     }
  769.     public function setKinestexPointsLow(?int $kinestexPointsLow): self
  770.     {
  771.         $this->kinestexPointsLow = $kinestexPointsLow;
  772.         return $this;
  773.     }
  774.     public function getKinestexPointsMedium(): ?int
  775.     {
  776.         return $this->kinestexPointsMedium;
  777.     }
  778.     public function setKinestexPointsMedium(?int $kinestexPointsMedium): self
  779.     {
  780.         $this->kinestexPointsMedium = $kinestexPointsMedium;
  781.         return $this;
  782.     }
  783.     public function getKinestexPointsHigh(): ?int
  784.     {
  785.         return $this->kinestexPointsHigh;
  786.     }
  787.     public function setKinestexPointsHigh(?int $kinestexPointsHigh): self
  788.     {
  789.         $this->kinestexPointsHigh = $kinestexPointsHigh;
  790.         return $this;
  791.     }
  792.     public function getKinestexExercise(): ?KinestexExercise
  793.     {
  794.         return $this->kinestexExercise;
  795.     }
  796.     public function setKinestexExercise(?KinestexExercise $kinestexExercise): self
  797.     {
  798.         $this->kinestexExercise = $kinestexExercise;
  799.         return $this;
  800.     }
  801.     public function getKinestexRepetitions(): ?int
  802.     {
  803.         return $this->kinestexRepetitions;
  804.     }
  805.     public function setKinestexRepetitions(?int $kinestexRepetitions): self
  806.     {
  807.         $this->kinestexRepetitions = $kinestexRepetitions;
  808.         return $this;
  809.     }
  810.     public function getKinestexDuration(): ?int
  811.     {
  812.         return $this->kinestexDuration;
  813.     }
  814.     public function setKinestexDuration(?int $kinestexDuration): self
  815.     {
  816.         $this->kinestexDuration = $kinestexDuration;
  817.         return $this;
  818.     }
  819.     public function getDailyRewardPoints(): ?int
  820.     {
  821.         return $this->dailyRewardPoints;
  822.     }
  823.     public function setDailyRewardPoints(?int $dailyRewardPoints): self
  824.     {
  825.         $this->dailyRewardPoints = $dailyRewardPoints;
  826.         return $this;
  827.     }
  828.     public function getNotificationBaseTime(): ?string
  829.     {
  830.         return $this->notificationBaseTime;
  831.     }
  832.     public function setNotificationBaseTime(?string $notificationBaseTime): self
  833.     {
  834.         $this->notificationBaseTime = $notificationBaseTime;
  835.         return $this;
  836.     }
  837.     public function getNotificationMaxOffset(): ?int
  838.     {
  839.         return $this->notificationMaxOffset;
  840.     }
  841.     public function setNotificationMaxOffset(?int $notificationMaxOffset): self
  842.     {
  843.         $this->notificationMaxOffset = $notificationMaxOffset;
  844.         return $this;
  845.     }
  846. }