src/Entity/User.php line 123

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiProperty;
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. use ApiPlatform\Core\Annotation\ApiSubresource;
  7. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  8. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\ExistsFilter;
  9. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  10. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  11. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
  12. use ApiPlatform\Core\Serializer\Filter\GroupFilter;
  13. use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
  14. use App\Annotation\SerializedNameGroups;
  15. use App\Repository\UserRepository;
  16. use App\Service\ToolsService;
  17. use Doctrine\Common\Collections\ArrayCollection;
  18. use Doctrine\Common\Collections\Collection;
  19. use Doctrine\ORM\Mapping as ORM;
  20. use Gedmo\Mapping\Annotation as Gedmo;
  21. use Hslavich\OneloginSamlBundle\Security\User\SamlUserInterface;
  22. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  23. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  24. use Symfony\Component\Security\Core\User\UserInterface;
  25. use Symfony\Component\Serializer\Annotation\Groups;
  26. use Symfony\Component\Security\Core\Validator\Constraints as SecurityAssert;
  27. use Symfony\Component\Validator\Constraints as Assert;
  28. use App\Entity\NotificationPreference;
  29. /**
  30.  * @ORM\Entity(repositoryClass=UserRepository::class)
  31.  * @ORM\Table(name="`user`")
  32.  * @ApiResource(
  33.  *     normalizationContext={"groups"={"user:read"}},
  34.  *     denormalizationContext={"groups"={"user:write"}},
  35.  *     subresourceOperations={
  36.  *          "users_favorites_get_subresource"={
  37.  *              "security"="is_granted('ROLE_ADMIN') or object == user"
  38.  *          }
  39.  *     },
  40.  *     itemOperations={
  41.  *         "get"={
  42.  *              "security"="is_granted('ROLE_USER')",
  43.  *              "security_message"="You are not allowed to access this ressource"
  44.  *          },
  45.  *         "patch"={
  46.  *              "security"="is_granted('ROLE_ADMIN') or is_granted('ROLE_COMPANY') or user == object"
  47.  *         },
  48.  *         "update_password"={
  49.  *              "method"="PATCH",
  50.  *              "input"="App\Dto\Security\PasswordUpdate",
  51.  *              "controller"="App\Controller\Api\UserController::updatePassword",
  52.  *              "path"="/users/{id}/update-pwd",
  53.  *              "security"="is_granted('ROLE_USER') and user.getId() === object.getId()",
  54.  *              "openapi_context"={
  55.  *                  "description" = "Updates pwd for the current user, it needs the current password, the new one and a confirmation of the new one",
  56.  *                  "summary" = "Updates pwd for the current user",
  57.  *              },
  58.  *         },
  59.  *     },
  60.  *     collectionOperations={
  61.  *          "get"={
  62.  *              "security"="is_granted('ROLE_USER')"
  63.  *          },
  64.  *          "tv_export"={
  65.  *              "security"="is_granted('ROLE_ADMIN')",
  66.  *              "method"="GET",
  67.  *              "controller"="App\Controller\Api\TvUserController::extractCsv",
  68.  *              "path"="/users/export",
  69.  *              "formats"={"csv"={"text/csv"}},
  70.  *              "pagination_enabled"=false,
  71.  *              "output"=Company::class,
  72.  *              "normalization_context"={"groups"={"user:read:export_csv"}}
  73.  *          },
  74.  *          "post"={
  75.  *              "security"="is_granted('ROLE_ADMIN')",
  76.  *              "normalization_context"={"groups"={"user:write:creation"}}
  77.  *          },
  78.  *          "api_users_import"={
  79.  *              "route_name"="api_users_import",
  80.  *              "description"="Import user",
  81.  *              "method"="post",
  82.  *              "openapi_context"={
  83.  *                  "description" = "This method imports a list of users from a csv",
  84.  *                  "summary" = "Imports several users",
  85.  *              },
  86.  *              "responses"={
  87.  *                  "200"={
  88.  *                      "description":"Users correctly created"
  89.  *                  }
  90.  *              },
  91.  *          }
  92.  *     }
  93.  * )
  94.  * @ApiFilter(OrderFilter::class, properties={"id", "username", "code", "active", "lastLogin", "status", "quotas"})
  95.  * @ApiFilter(SearchFilter::class, properties={"code": "partial", "status": "exact", "id": "partial", "username": "partial", "email": "partial"})
  96.  * @ApiFilter(BooleanFilter::class, properties={"active", "newsletter"})
  97.  * @ApiFilter(ExistsFilter::class, properties={"deviceToken"})
  98.  * @ApiFilter(DateFilter::class, properties={"lastLogin"})
  99.  * @ApiFilter(GroupFilter::class, 
  100.  *      arguments={
  101.  *          "parameterName": "groups", 
  102.  *          "overrideDefaultGroups": true, 
  103.  *          "whitelist": {"user:read:tuto_only", "user:read:form"}
  104.  *      }
  105.  * )
  106.  * @ApiFilter(PropertyFilter::class, 
  107.  *      arguments={
  108.  *          "parameterName"="fields", 
  109.  *          "overrideDefaultProperties"=true
  110.  *     }
  111.  * )
  112.  * @UniqueEntity(
  113.  *     fields={"email", "category"},
  114.  *     errorPath="email",
  115.  *     message="The email is already in use",
  116.  *     ignoreNull=false
  117.  * )
  118.  * @ORM\HasLifecycleCallbacks()
  119.  */
  120. class User implements UserInterface, PasswordAuthenticatedUserInterface, SamlUserInterface
  121. {
  122.     const QUOTA_DAY = 'daily';
  123.     const QUOTA_WEEK = 'weekly';
  124.     const QUOTA_MONTH = 'monthly';
  125.     const QUOTA_NONE = 'unset';
  126.     const STATUS_ACTIVE = 'active';
  127.     const STATUS_SUSPENDED = 'suspended';
  128.     const STATUSES = [
  129.         self::STATUS_ACTIVE,
  130.         self::STATUS_SUSPENDED,
  131.     ];
  132.     const QUOTAS = [
  133.         self::QUOTA_DAY,
  134.         self::QUOTA_WEEK,
  135.         self::QUOTA_MONTH,
  136.     ];
  137.     /**
  138.      * Associative array, keys are the quotas types (none excluded)
  139.      * values are the string to pass to a datetime object
  140.      */
  141.     const QUOTAS_VAlUES = [
  142.         self::QUOTA_DAY => '1 day',
  143.         self::QUOTA_WEEK => '1 week',
  144.         self::QUOTA_MONTH => '1 month',
  145.     ];
  146.     const GROUP_ADMIN = 'admin';
  147.     const GROUP_COMPANY = 'company';
  148.     const GROUP_CLIENT = 'client';
  149.     const GROUP_SPECIALIST = 'specialist';
  150.     const ROLE_USER = 'ROLE_USER';
  151.     const ROLE_CLIENT = 'ROLE_CLIENT';
  152.     const ROLE_COMPANY = 'ROLE_COMPANY';
  153.     const ROLE_EXTERNAL_COMPANY = 'ROLE_EXTERNAL_COMPANY';
  154.     const ROLE_ADMIN = 'ROLE_ADMIN';
  155.     const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';
  156.     const ROLE_SPECIALIST = 'ROLE_SPECIALIST';
  157.     const ROLE_TV = 'ROLE_TV';
  158.     const ROLE_LIVE = 'ROLE_LIVE';
  159.     const GROUPS = [
  160.         self::GROUP_ADMIN,
  161.         self::GROUP_COMPANY,
  162.         self::GROUP_CLIENT,
  163.         self::GROUP_SPECIALIST,
  164.     ];
  165.     /**
  166.      * @ORM\Id
  167.      * @ORM\GeneratedValue
  168.      * @ORM\Column(type="integer")
  169.      * @Groups({
  170.      *      "user_favorite:read", "user:read:id", "user:read", "company:read", "user:read:export_csv", 
  171.      *      "team:read", "team_user:read", "user:read:form", "notification:read", "client:read",
  172.      *      "chat_message:read", "chat:read", "message:read"
  173.      * })
  174.      */
  175.     private $id;
  176.     /**
  177.      * @ORM\Column(type="string", length=180)
  178.      * @Assert\Email
  179.      * @Assert\NotBlank
  180.      * @Groups({
  181.      *      "user_favorite:read", "user:read:email", "user:read", "user:write:creation", "user:write", 
  182.      *      "team:read", "team_user:read", "user:read:form", "notification:read", "company:read", "company:write", 
  183.      *      "client:read", "client:write", "chat_message:read", "chat:read", "message:read"
  184.      * })
  185.      */
  186.     private $email;
  187.     /**
  188.      * @ORM\Column(type="json")
  189.      * @Groups({"user:read:roles", "user:read", "user_favorite:read", "client:read"})
  190.      */
  191.     private $roles = [];
  192.     /**
  193.      * @var string|null The hashed password
  194.      * @ORM\Column(type="string")
  195.      * @Assert\Length(min="8", max="255")
  196.      * @Assert\NotBlank
  197.      */
  198.     private $password = null;
  199.     /**
  200.      * @var string|null
  201.      * @Assert\NotBlank(
  202.      *      groups={"user:update:password"}
  203.      * )
  204.      * @SecurityAssert\UserPassword(
  205.      *      message="old_password.matching",
  206.      *      groups={"user:update:password"}
  207.      * )
  208.      */
  209.     private $oldPassword = null;
  210.     /**
  211.      * @var string|null
  212.      * @Groups({"user:write:creation", "user:write", "user:read:creation"})
  213.      * @Assert\Regex("/(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}/", 
  214.      *      message="password.pattern",
  215.      *      groups={"user:write:reset-password", "user:update:password"}
  216.      * )
  217.      * @Assert\NotBlank(
  218.      *      groups={"user:write:reset-password", "user:update:password"}
  219.      * )
  220.      * @Assert\Length(
  221.      *      min=6, 
  222.      *      max=4096,
  223.      *      minMessage="Your password should be at least {{ limit }} characters",
  224.      *      groups={"user:write:reset-password", "user:update:password"}
  225.      * )
  226.      * @SerializedNameGroups(name="Mot-de-passe", groups={"user:read:creation"})
  227.      */
  228.     private $plainPassword = null;
  229.     /**
  230.      * @var string|null
  231.      * @Groups({"user:write:creation", "user:write"})
  232.      * @Assert\IdenticalTo(propertyPath="plainPassword", 
  233.      *      message="password.matching",
  234.      *      groups={"user:write:reset-password", "user:update:password"}
  235.      * )
  236.      */
  237.     private $passwordConfirm = null;
  238.     /**
  239.      * @ORM\Column(type="datetime")
  240.      * @Gedmo\Timestampable(on="create")
  241.      * @Groups({"user:read:createdAt", "user:read"})
  242.      */
  243.     private $createdAt;
  244.     /**
  245.      * @ORM\Column(type="datetime", nullable=true)
  246.      * @Gedmo\Timestampable(on="update")
  247.      * @Groups({"user:read:updatedAt", "user:read"})
  248.      */
  249.     private $updatedAt;
  250.     /**
  251.      * @ORM\Column(type="datetime", nullable=true)
  252.      * @Groups({"user:read:lastLogin", "user:read", "user:write", "client:read"})
  253.      */
  254.     private $lastLogin;
  255.     /**
  256.      * @ORM\Column(type="string", length=255)
  257.      * @Assert\Length(max="255", min="0")
  258.      * @Groups({"user:read:name", "user:read", "user_favorite:read", "chat_message:read", "chat:read"})
  259.      * @var string
  260.      */
  261.     private $name = '';
  262.     /**
  263.      * @ORM\Column(type="string", length=50)
  264.      * @Assert\Choice(choices=self::GROUPS)
  265.      * @Groups({"user:read:category", "user:read", "user_favorite:read"})
  266.      */
  267.     private $category;
  268.     /**
  269.      * @ORM\Column(type="boolean", options={"default": "1"})
  270.      * @Groups({"user_favorite:read", "user:read:active", "user:read", "company:read", "user:read:export_csv", "notification:read", "chat_message:read", "chat:read", "client:read"})
  271.      */
  272.     private $active = true;
  273.     /**
  274.      * @ORM\Column(type="datetime", nullable=true)
  275.      */
  276.     private $banStart;
  277.     /**
  278.      * @ORM\Column(type="datetime", nullable=true)
  279.      */
  280.     private $banEnd;
  281.     /**
  282.      * @ORM\Column(type="string", length=255, nullable=true, unique=true)
  283.      */
  284.     private $resetToken;
  285.     /**
  286.      * @ORM\OneToOne(targetEntity=Specialist::class, mappedBy="user", cascade={"persist", "remove"})
  287.      */
  288.     private $specialist;
  289.     /**
  290.      * @ORM\OneToOne(targetEntity=Company::class, mappedBy="user", cascade={"persist", "remove"})
  291.      * @ApiProperty(security="is_granted('ROLE_ADMIN') or is_granted('ROLE_COMPANY')")
  292.      * @Groups({"user:read:company", "user:read", "message:read"})
  293.      */
  294.     private $company;
  295.     /**
  296.      * @ORM\OneToOne(targetEntity=Client::class, mappedBy="user", cascade={"persist", "remove"})
  297.      * @Groups({"user:read:client", "user:read", "team_user:read", "chat_message:read", "chat:read", "message:read"})
  298.      */
  299.     private $client;
  300.     /**
  301.      * @var bool
  302.      */
  303.     private $_hashPwd = false;
  304.     /**
  305.      * @var null|string
  306.      */
  307.     private $token = null;
  308.     /**
  309.      * @ORM\OneToMany(targetEntity=Document::class, mappedBy="owner")
  310.      */
  311.     private $documents;
  312.     /**
  313.      * @ORM\OneToMany(targetEntity=MarketplaceReservation::class, mappedBy="user", cascade={"persist", "refresh", "remove"})
  314.      */
  315.     private $marketplaceReservations;
  316.     /**
  317.      * @ORM\Column(type="string", length=255, nullable=true)
  318.      * @Groups({"user:read:firstName", "user:read", "user_favorite:read", "company:read", "company:write", "team_user:read", "chat_message:read", "chat:read"})
  319.      */
  320.     private $firstName;
  321.     /**
  322.      * @ORM\Column(type="string", length=255, nullable=true)
  323.      * @Groups({"user:read:lastName", "user:read", "user_favorite:read", "company:read", "company:write", "team_user:read", "chat_message:read", "chat:read"})
  324.      */
  325.     private $lastName;
  326.     /**
  327.      * @ORM\OneToMany(targetEntity=UserFavorite::class, mappedBy="user", cascade={"persist", "refresh", "remove"})
  328.      * @Groups({"user:read:favorites"})
  329.      * @ApiSubresource(maxDepth=1)
  330.      */
  331.     private $favorites;
  332.     /**
  333.      * @ORM\ManyToOne(targetEntity=Segmentation::class, inversedBy="users", cascade={"persist"})
  334.      * @Groups({"user:read:segmentation", "user:read", "user:write", "chat_message:read", "chat:read"})
  335.      */
  336.     private $segmentation;
  337.     /**
  338.      * Valeurs de segmentation multi-axes â€” source de vérité des affectations,
  339.      * synchronisée automatiquement par setSegmentation() / assignSegmentationValue()
  340.      *
  341.      * @ORM\OneToMany(targetEntity=UserSegmentation::class, mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true)
  342.      * @Groups({"user:read:segmentations"})
  343.      */
  344.     private $userSegmentations;
  345.     /**
  346.      * @ORM\Column(type="string", length=255, nullable=true, options={"default": "FR"})
  347.      * @Groups({"user:read:country"})
  348.      */
  349.     private $country;
  350.     /**
  351.      * @ORM\Column(name="`function`", type="string", length=255, nullable=true)
  352.      * @Groups({"user:read:function", "user:read", "user:write", "company:read", "company:write", "export_csv", "manager_dashboard"})
  353.      */
  354.     private $function;
  355.     /**
  356.      * @ORM\Column(type="string", length=255, nullable=true)
  357.      * @Groups({"user:read:phone", "user:read", "user:write", "company:read", "company:write", "export_csv", "manager_dashboard"})
  358.      * @Assert\Length(min=8, max=20, minMessage="phone.min", maxMessage="phone.max")
  359.      */
  360.     private $phone;
  361.     /**
  362.      * @ORM\Column(type="string", length=255, nullable=true)
  363.      * @Groups({"user:read:username", "user:read", "user:write:creation", "user:write", "team:read", "team_user:read", "user:read:form", "notification:read", "chat_message:read", "chat:read"})
  364.      */
  365.     private $username;
  366.     /**
  367.      * @ORM\Column(type="integer", options={"default": "-1"})
  368.      * @Groups({"user:read:quotas", "user:read", "user:write", "user:read:export_csv"})
  369.      */
  370.     private $quotas = -1;
  371.     /**
  372.      * @ORM\Column(type="string", length=255, options={"default": "unset"})
  373.      * @Groups({"user:read:quotasType", "user:read", "user:write", "user:read:export_csv"})
  374.      */
  375.     private $quotasType = self::QUOTA_NONE;
  376.     /**
  377.      * @ORM\Column(type="datetime", nullable=true)
  378.      * @Gedmo\Timestampable(on="change", field="email")
  379.      */
  380.     private $emailUpdatedAt;
  381.     /**
  382.      * @ORM\Column(type="datetime", nullable=true)
  383.      */
  384.     private $emailValidatedAt;
  385.     /**
  386.      * @ORM\Column(type="string", length=255, nullable=true)
  387.      * @Groups({"user:read:status", "user:read", "company:read", "user:read:export_csv", "client:read"})
  388.      * @Assert\Choice(choices=self::STATUSES)
  389.      */
  390.     private $status = self::STATUS_ACTIVE;
  391.     /**
  392.      * @ORM\Column(type="string", length=255, nullable=true)
  393.      * @Groups({"user:read:deviceOs", "user:read", "user:write"})
  394.      */
  395.     private $deviceOs;
  396.     /**
  397.      * @ORM\Column(type="text", nullable=true)
  398.      * @Groups({"user:read:deviceToken", "user:read", "user:write"})
  399.      */
  400.     private $deviceToken;
  401.     /**
  402.      * @ORM\Column(type="string", length=255, nullable=true)
  403.      * @Groups({"user:read:deviceName", "user:read", "user:write"})
  404.      */
  405.     private $deviceName;
  406.     /**
  407.      * @ORM\Column(type="boolean", nullable=true, options={"default": 1})
  408.      * @Groups({"user:read:deviceActive", "user:read", "user:write"})
  409.      */
  410.     private $deviceActive = true;
  411.     /**
  412.      * @ORM\Column(type="datetime", nullable=true)
  413.      * @Gedmo\Timestampable(on="change", field={"deviceOs", "deviceToken", "deviceName", "deviceActive"})
  414.      * @Groups({"user:read:deviceUpdate", "user:read", "user:write"})
  415.      */
  416.     private $deviceUpdate;
  417.     /**
  418.      * @ORM\OneToMany(targetEntity=UserDevice::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  419.      */
  420.     private $devices;
  421.     /**
  422.      * @ORM\Column(type="boolean", options={"default": "0"})
  423.      * @Groups({"user:read:newsletter", "user:read", "company:read", "user:write", "client:read", "client:write"})
  424.      */
  425.     private $newsletter = false;
  426.     /**
  427.      * @ORM\Column(type="datetime", nullable=true)
  428.      * @Groups({"user:read:newsletterDate", "user:read", "company:read"})
  429.      * @Gedmo\Timestampable(on="change", field="newsletter", value=true)
  430.      */
  431.     private $newsletterDate;
  432.     /**
  433.      * @ORM\Column(type="boolean", options={"default": "1"})
  434.      * @Groups({"user:read:firstLogin", "user:read", "company:read", "user:write", "client:read", "client:write"})
  435.      */
  436.     private $firstLogin = true;
  437.     /**
  438.      * @ORM\Column(type="boolean", options={"default": "1"})
  439.      * @Groups({"user:read:homeSurvey", "user:read", "company:read", "user:write", "client:read", "client:write"})
  440.      */
  441.     private $homeSurvey = true;
  442.     /**
  443.      * @ORM\Column(type="boolean", nullable=true, options={"default": "1"})
  444.      * @Groups({"user:read:displayTeamplayTuto", "user:read", "user:write", "user:read:tuto_only", "client:read", "client:write"})
  445.      */
  446.     private $displayTeamplayTuto = true;
  447.     /**
  448.      * @ORM\OneToMany(targetEntity=Log::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  449.      */
  450.     private $logs;
  451.     /**
  452.      * Sent messages by the user to web admins
  453.      * @ORM\OneToMany(targetEntity=Message::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  454.      */
  455.     private $messages;
  456.     /**
  457.      * @ORM\OneToMany(targetEntity=VideoEvent::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  458.      */
  459.     private $videoEvents;
  460.     /**
  461.      * @ORM\OneToMany(targetEntity=UserResponse::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  462.      */
  463.     private $userResponses;
  464.     /**
  465.      * @ORM\OneToMany(targetEntity=Favorite::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  466.      * @Groups({"user:read:tvFavorites"})
  467.      * @ApiSubresource(maxDepth=1)
  468.      */
  469.     private $tvFavorites;
  470.     /**
  471.      * @ORM\OneToMany(targetEntity=LogEmail::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  472.      */
  473.     private $logEmails;
  474.     /**
  475.      * @ORM\OneToMany(targetEntity=Playlist::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  476.      */
  477.     private $playlists;
  478.     /**
  479.      * @ORM\ManyToMany(targetEntity=Objective::class, mappedBy="users")
  480.      * @Groups({"user:read", "user:write"})
  481.      */
  482.     private $objectives;
  483.     /**
  484.      * @ORM\OneToMany(targetEntity=TeamUser::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  485.      */
  486.     private $teamUsers;
  487.     /**
  488.      * @ORM\OneToMany(targetEntity=TeamplayLog::class, mappedBy="user", orphanRemoval=true, cascade={"refresh", "remove"})
  489.      */
  490.     private $teamplayLogs;
  491.     /**
  492.      * @ORM\OneToMany(targetEntity=PedometerLog::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  493.      */
  494.     private $pedometerLogs;
  495.     /**
  496.      * @ORM\OneToMany(targetEntity=UserNotification::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  497.      */
  498.     private $userNotifications;
  499.     /**
  500.      * @ORM\OneToMany(targetEntity=AwardLog::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  501.      */
  502.     private $awardLogs;
  503.     /**
  504.      * @ORM\OneToMany(targetEntity=UserVideoTimecode::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  505.      */
  506.     private $userVideoTimecodes;
  507.     /**
  508.      * @ORM\OneToMany(targetEntity=Notation::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  509.      */
  510.     private $notations;
  511.     /**
  512.      * @ORM\OneToMany(targetEntity=VideoLastValidate::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  513.      */
  514.     private $videoLastValidates;
  515.     /**
  516.      * @ORM\OneToMany(targetEntity=VideoLastSeen::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  517.      */
  518.     private $videoLastSeens;
  519.     /**
  520.      * @ORM\OneToMany(targetEntity=MoodResponse::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  521.      */
  522.     private $moodResponses;
  523.     /**
  524.      * @ORM\OneToMany(targetEntity=ProgramEvent::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  525.      */
  526.     private $programEvents;
  527.     /**
  528.      * @ORM\OneToMany(targetEntity=DayEvent::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  529.      */
  530.     private $dayEvents;
  531.     /**
  532.      * @ORM\OneToOne(targetEntity=TvUser::class, mappedBy="user", cascade={"persist", "refresh","remove"})
  533.      */
  534.     private $tvUser;
  535.     /**
  536.      * @ORM\Column(type="boolean", options={"default": "1"})
  537.      * @Groups({"user:read:live", "user:read", "user:write",  "user_favorite:read", "client:read"})
  538.      */
  539.     private $live = true;
  540.     /**
  541.      * @ORM\Column(type="boolean", options={"default": "1"})
  542.      * @Groups({"user:read:tv", "user:read", "user:write",  "user_favorite:read", "client:read"})
  543.      */
  544.     private $tv = true;
  545.     /**
  546.      *  
  547.      * @ORM\ManyToMany(targetEntity=Chat::class, inversedBy="users")
  548.      */
  549.     private $chats;
  550.     /**
  551.      * @var bool
  552.      */
  553.     public $isPopulated = false;
  554.     /**
  555.      * @ORM\OneToMany(targetEntity=Invoice::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true) 
  556.      */
  557.     private $invoices;
  558.     /**
  559.      * @ORM\OneToOne(targetEntity=NotificationPreference::class, mappedBy="user", cascade={"persist","remove"})
  560.      */
  561.     private $notificationPreference = null;
  562.     /**
  563.      * @ORM\OneToOne(targetEntity=StravaProfile::class, mappedBy="user", cascade={"persist", "remove"})
  564.      * @Groups({"user:read:stravaProfile", "user:read"})
  565.      */
  566.     private $stravaProfile;
  567.     public function __construct()
  568.     {
  569.         $this->roles[] = self::ROLE_USER;
  570.         $this->documents = new ArrayCollection();
  571.         $this->marketplaceReservations = new ArrayCollection();
  572.         $this->favorites = new ArrayCollection();
  573.         $this->devices = new ArrayCollection();
  574.         $this->logs = new ArrayCollection();
  575.         $this->messages = new ArrayCollection();
  576.         $this->videoEvents = new ArrayCollection();
  577.         $this->userResponses = new ArrayCollection();
  578.         $this->tvFavorites = new ArrayCollection();
  579.         $this->logEmails = new ArrayCollection();
  580.         $this->playlists = new ArrayCollection();
  581.         $this->objectives = new ArrayCollection();
  582.         $this->teamUsers = new ArrayCollection();
  583.         $this->teamplayLogs = new ArrayCollection();
  584.         $this->pedometerLogs = new ArrayCollection();
  585.         $this->userNotifications = new ArrayCollection();
  586.         $this->awardLogs = new ArrayCollection();
  587.         $this->userVideoTimecodes = new ArrayCollection();
  588.         $this->notations = new ArrayCollection();
  589.         $this->videoLastValidates = new ArrayCollection();
  590.         $this->videoLastSeens = new ArrayCollection();
  591.         $this->moodResponses = new ArrayCollection();
  592.         $this->programEvents = new ArrayCollection();
  593.         $this->dayEvents = new ArrayCollection();
  594.         $this->chats = new ArrayCollection();
  595.         $this->invoices = new ArrayCollection();
  596.         $this->userSegmentations = new ArrayCollection();
  597.     }
  598.     public function getId(): ?int
  599.     {
  600.         return $this->id;
  601.     }
  602.     public function getEmail(): ?string
  603.     {
  604.         return $this->email;
  605.     }
  606.     public function setEmail(string $email): self
  607.     {
  608.         $this->email = $email;
  609.         return $this;
  610.     }
  611.     /**
  612.      * A visual identifier that represents this user.
  613.      *
  614.      * @see UserInterface
  615.      */
  616.     public function getUserIdentifier(): string
  617.     {
  618.         return (string)$this->email;
  619.     }
  620.     public function getUsername(): ?string
  621.     {
  622.         return $this->username;
  623.     }
  624.     public function setUsername(?string $username): self
  625.     {
  626.         $this->username = $username;
  627.         return $this;
  628.     }
  629.     /**
  630.      * @see UserInterface
  631.      */
  632.     public function getRoles(): array
  633.     {
  634.         $roles = $this->roles;
  635.         // guarantee every user at least has ROLE_USER
  636.         $roles[] = self::ROLE_USER;
  637.         if ($this->isTv()) {
  638.             $roles[] = self::ROLE_TV;
  639.         }
  640.         if ($this->isLive()) {
  641.             $roles[] = self::ROLE_LIVE;
  642.         }
  643.         return array_unique($roles);
  644.     }
  645.     /**
  646.      * @param string $role
  647.      * @return bool
  648.      */
  649.     public function hasRole(string $role): bool
  650.     {
  651.         return in_array($role, $this->roles);
  652.     }
  653.     /**
  654.      * @see UserInterface
  655.      */
  656.     public function addRole(string $role): self
  657.     {
  658.         if (!in_array($role, $this->roles)) {
  659.             $this->roles[] = $role;
  660.         }
  661.         return $this;
  662.     }
  663.     /**
  664.      * @see UserInterface
  665.      */
  666.     public function removeRole(string $role): self
  667.     {
  668.         if (in_array($role, $this->roles)) {
  669.             foreach ($this->roles as $key => $item) {
  670.                 if ($item === $role) {
  671.                     unset($this->roles[$key]);
  672.                 }
  673.             }
  674.             $this->roles = array_values($this->roles);
  675.         }
  676.         return $this;
  677.     }
  678.     public function setRoles(array $roles): self
  679.     {
  680.         $this->roles = $roles;
  681.         return $this;
  682.     }
  683.     /**
  684.      * @see PasswordAuthenticatedUserInterface
  685.      */
  686.     public function getPassword(): ?string
  687.     {
  688.         return $this->password;
  689.     }
  690.     /**
  691.      * This setter also checks if the password has changed it will rehash it
  692.      * @param string|null $password New password
  693.      * @param bool $hash Forces rehash of password
  694.      * @return $this
  695.      */
  696.     public function setPassword(?string $password, bool $hash = false): self
  697.     {
  698.         if (!empty($password) && ($this->password !== $password || $hash)) {
  699.             $this->_hashPwd = true;
  700.         }
  701.         if (!empty($password)) {
  702.             $this->password = $password;
  703.         }
  704.         return $this;
  705.     }
  706.     /**
  707.      * If persisted this password will be encoded into the password field
  708.      * @param ?string $oldPassword
  709.      * @return User
  710.      */
  711.     public function setOldPassword(?string $oldPassword): User
  712.     {
  713.         $this->oldPassword = $oldPassword;
  714.         return $this;
  715.     }
  716.     /**
  717.      * @return string
  718.      */
  719.     public function getOldPassword(): ?string
  720.     {
  721.         return $this->oldPassword;
  722.     }
  723.     /**
  724.      * If persisted this password will be encoded into the password field
  725.      * @param string $password
  726.      * @return User
  727.      */
  728.     public function setPlainPassword(string $password): User
  729.     {
  730.         $this->plainPassword = $password;
  731.         return $this;
  732.     }
  733.     /**
  734.      * @return string
  735.      */
  736.     public function getPlainPassword(): ?string
  737.     {
  738.         return $this->plainPassword;
  739.     }
  740.     /**
  741.      * @return string|null
  742.      */
  743.     public function getPasswordConfirm(): ?string
  744.     {
  745.         return $this->passwordConfirm;
  746.     }
  747.     /**
  748.      * @param string|null $passwordConfirm
  749.      * @return User
  750.      */
  751.     public function setPasswordConfirm(?string $passwordConfirm): User
  752.     {
  753.         $this->passwordConfirm = $passwordConfirm;
  754.         return $this;
  755.     }
  756.     /**
  757.      * Returning a salt is only needed, if you are not using a modern
  758.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  759.      *
  760.      * @see UserInterface
  761.      */
  762.     public function getSalt(): ?string
  763.     {
  764.         return null;
  765.     }
  766.     /**
  767.      * @see UserInterface
  768.      */
  769.     public function eraseCredentials()
  770.     {
  771.         // If you store any temporary, sensitive data on the user, clear it here
  772.         $this->plainPassword = null;
  773.     }
  774.     public function getCreatedAt(): ?\DateTime
  775.     {
  776.         return $this->createdAt;
  777.     }
  778.     public function setCreatedAt(\DateTime $createdAt): self
  779.     {
  780.         $this->createdAt = $createdAt;
  781.         return $this;
  782.     }
  783.     public function getUpdatedAt(): ?\DateTime
  784.     {
  785.         return $this->updatedAt;
  786.     }
  787.     public function setUpdatedAt(\DateTime $updatedAt): self
  788.     {
  789.         $this->updatedAt = $updatedAt;
  790.         return $this;
  791.     }
  792.     public function getLastLogin(): ?\DateTimeInterface
  793.     {
  794.         return $this->lastLogin;
  795.     }
  796.     public function setLastLogin(?\DateTimeInterface $lastLogin): self
  797.     {
  798.         $this->lastLogin = $lastLogin;
  799.         return $this;
  800.     }
  801.     public function getName(): ?string
  802.     {
  803.         return $this->name;
  804.     }
  805.     public function setName(?string $name): self
  806.     {
  807.         $this->name = $name;
  808.         return $this;
  809.     }
  810.     public function getCategory(): ?string
  811.     {
  812.         return $this->category;
  813.     }
  814.     public function setCategory(string $category): self
  815.     {
  816.         $this->category = $category;
  817.         return $this;
  818.     }
  819.     public function getActive(): ?bool
  820.     {
  821.         return $this->active;
  822.     }
  823.     public function isActive(): ?bool
  824.     {
  825.         return $this->active;
  826.     }
  827.     public function setActive(bool $active): self
  828.     {
  829.         $this->active = $active;
  830.         if ($this->active) {
  831.             $this->status = self::STATUS_ACTIVE;
  832.         } else {
  833.             $this->status = self::STATUS_SUSPENDED;
  834.         }
  835.         return $this;
  836.     }
  837.     public function getBanStart(): ?\DateTimeInterface
  838.     {
  839.         return $this->banStart;
  840.     }
  841.     public function setBanStart(?\DateTimeInterface $banStart): self
  842.     {
  843.         $this->banStart = $banStart;
  844.         return $this;
  845.     }
  846.     public function getBanEnd(): ?\DateTimeInterface
  847.     {
  848.         return $this->banEnd;
  849.     }
  850.     public function setBanEnd(?\DateTimeInterface $banEnd): self
  851.     {
  852.         $this->banEnd = $banEnd;
  853.         return $this;
  854.     }
  855.     public function getResetToken(): ?string
  856.     {
  857.         return $this->resetToken;
  858.     }
  859.     public function setResetToken(?string $resetToken): self
  860.     {
  861.         $this->resetToken = $resetToken;
  862.         return $this;
  863.     }
  864.     public function getSpecialist(): ?Specialist
  865.     {
  866.         return $this->specialist;
  867.     }
  868.     public function setSpecialist(Specialist $specialist): self
  869.     {
  870.         // set the owning side of the relation if necessary
  871.         if ($specialist->getUser() !== $this) {
  872.             $specialist->setUser($this);
  873.         }
  874.         $this->specialist = $specialist;
  875.         return $this;
  876.     }
  877.     public function getCompany(): ?Company
  878.     {
  879.         return $this->company;
  880.     }
  881.     public function setCompany(?Company $company): self
  882.     {
  883.         $this->company = $company;
  884.         return $this;
  885.     }
  886.     public function getClient(): ?Client
  887.     {
  888.         return $this->client;
  889.     }
  890.     public function setClient(Client $client): self
  891.     {
  892.         // set the owning side of the relation if necessary
  893.         if ($client->getUser() !== $this) {
  894.             $client->setUser($this);
  895.         }
  896.         $this->client = $client;
  897.         return $this;
  898.     }
  899.     /**
  900.      * @return bool
  901.      */
  902.     public function isHashPwd(): bool
  903.     {
  904.         return $this->_hashPwd;
  905.     }
  906.     /**
  907.      * @return string
  908.      */
  909.     public function __toString()
  910.     {
  911.         return $this->name;
  912.     }
  913.     /**
  914.      * @ORM\PrePersist()
  915.      */
  916.     public function updateName()
  917.     {
  918.         if ($this->company instanceof Company) {
  919.             $this->name = $this->company->getName();
  920.         } elseif ($this->specialist instanceof Specialist) {
  921.             $this->name = (string)$this->specialist;
  922.         } elseif ($this->client instanceof Client) {
  923.             $this->name = (string)$this->client;
  924.         }
  925.     }
  926.     /**
  927.      * @param string|null $token
  928.      * @return User
  929.      */
  930.     public function setToken(?string $token): User
  931.     {
  932.         $this->token = $token;
  933.         return $this;
  934.     }
  935.     /**
  936.      * @return string|null
  937.      */
  938.     public function getToken(): ?string
  939.     {
  940.         return $this->token;
  941.     }
  942.     public function setSamlAttributes(array $attributes)
  943.     {
  944.         $this->token = $attributes['sessionIndex'];
  945.         $data = [];
  946.         foreach ($attributes as $key => $value) {
  947.             $data[ToolsService::toCamelCase($key)] = $value;
  948.         }
  949.         if (!empty($data['email'])) {
  950.             if (is_array($data['email'])) $this->email = $data['email'][0];
  951.             elseif (is_string($data['email'])) $this->email = $data['email'];
  952.         }
  953.         if (!empty($data['firstName'])) {
  954.             if (is_array($data['firstName'])) $this->firstName = $data['firstName'][0];
  955.             elseif (is_string($data['firstName'])) $this->firstName = $data['firstName'];
  956.         }
  957.         if (!empty($data['lastName'])) {
  958.             if (is_array($data['lastName'])) $this->lastName = $data['lastName'][0];
  959.             elseif (is_string($data['lastName'])) $this->lastName = $data['lastName'];
  960.         }
  961.         if (!empty($data['country'])) {
  962.             if (is_array($data['country'])) $this->country = $data['country'][0];
  963.             elseif (is_string($data['country'])) $this->country = $data['country'];
  964.         }
  965.     }
  966.     /**
  967.      * @return Collection<int, Document>
  968.      */
  969.     public function getDocuments(): Collection
  970.     {
  971.         return $this->documents;
  972.     }
  973.     public function addDocument(Document $document): self
  974.     {
  975.         if (!$this->documents->contains($document)) {
  976.             $this->documents[] = $document;
  977.             $document->setOwner($this);
  978.         }
  979.         return $this;
  980.     }
  981.     public function removeDocument(Document $document): self
  982.     {
  983.         if ($this->documents->removeElement($document)) {
  984.             // set the owning side to null (unless already changed)
  985.             if ($document->getOwner() === $this) {
  986.                 $document->setOwner(null);
  987.             }
  988.         }
  989.         return $this;
  990.     }
  991.     /**
  992.      * @return Collection<int, MarketplaceReservation>
  993.      */
  994.     public function getMarketplaceReservations(): Collection
  995.     {
  996.         return $this->marketplaceReservations;
  997.     }
  998.     public function addMarketplaceReservation(MarketplaceReservation $marketplaceReservation): self
  999.     {
  1000.         if (!$this->marketplaceReservations->contains($marketplaceReservation)) {
  1001.             $this->marketplaceReservations[] = $marketplaceReservation;
  1002.             $marketplaceReservation->setUser($this);
  1003.         }
  1004.         return $this;
  1005.     }
  1006.     public function removeMarketplaceReservation(MarketplaceReservation $marketplaceReservation): self
  1007.     {
  1008.         if ($this->marketplaceReservations->removeElement($marketplaceReservation)) {
  1009.             // set the owning side to null (unless already changed)
  1010.             if ($marketplaceReservation->getUser() === $this) {
  1011.                 $marketplaceReservation->setUser(null);
  1012.             }
  1013.         }
  1014.         return $this;
  1015.     }
  1016.     public function getFirstName(): ?string
  1017.     {
  1018.         return $this->firstName;
  1019.     }
  1020.     public function setFirstName(?string $firstName): self
  1021.     {
  1022.         $this->firstName = $firstName;
  1023.         $name = $this->firstName;
  1024.         if (!empty($this->lastName)) {
  1025.             $name .= " " . $this->lastName;
  1026.         }
  1027.         $this->setName($name);
  1028.         return $this;
  1029.     }
  1030.     public function getLastName(): ?string
  1031.     {
  1032.         return $this->lastName;
  1033.     }
  1034.     public function setLastName(?string $lastName): self
  1035.     {
  1036.         $this->lastName = $lastName;
  1037.         $name = $this->firstName;
  1038.         if (!empty($this->lastName)) {
  1039.             $name .= " " . $this->lastName;
  1040.         }
  1041.         $this->setName($name);
  1042.         return $this;
  1043.     }
  1044.     /**
  1045.      * @return Collection<int, UserFavorite>
  1046.      */
  1047.     public function getFavorites(): Collection
  1048.     {
  1049.         return $this->favorites;
  1050.     }
  1051.     public function addFavorite(UserFavorite $favorite): self
  1052.     {
  1053.         if (!$this->favorites->contains($favorite)) {
  1054.             $this->favorites[] = $favorite;
  1055.             $favorite->setUser($this);
  1056.         }
  1057.         return $this;
  1058.     }
  1059.     public function removeFavorite(UserFavorite $favorite): self
  1060.     {
  1061.         if ($this->favorites->removeElement($favorite)) {
  1062.             // set the owning side to null (unless already changed)
  1063.             if ($favorite->getUser() === $this) {
  1064.                 $favorite->setUser(null);
  1065.             }
  1066.         }
  1067.         return $this;
  1068.     }
  1069.     public function getSegmentation(): ?Segmentation
  1070.     {
  1071.         return $this->segmentation;
  1072.     }
  1073.     public function setSegmentation(?Segmentation $segmentation): self
  1074.     {
  1075.         $previous            = $this->segmentation;
  1076.         $this->segmentation  = $segmentation;
  1077.         if ($this->getClient()) {
  1078.             $this->getClient()->setSegmentation($segmentation);
  1079.         }
  1080.         // Invariant multi-axes : la valeur miroir doit toujours exister dans user_segmentation
  1081.         if ($segmentation instanceof Segmentation) {
  1082.             $this->syncSegmentationValue($segmentation);
  1083.         } elseif ($previous instanceof Segmentation) {
  1084.             $this->removeSegmentationValue($previous);
  1085.         }
  1086.         return $this;
  1087.     }
  1088.     /**
  1089.      * @return Collection<int, UserSegmentation>
  1090.      */
  1091.     public function getUserSegmentations(): Collection
  1092.     {
  1093.         return $this->userSegmentations;
  1094.     }
  1095.     /**
  1096.      * Affecte une valeur de segmentation multi-axes : remplace la valeur du même axe dans le pivot.
  1097.      * Si la valeur remplacée est celle portée par le miroir legacy (segmentation_id), le miroir suit.
  1098.      */
  1099.     public function assignSegmentationValue(Segmentation $segmentation): self
  1100.     {
  1101.         if ($this->segmentation instanceof Segmentation
  1102.             && !$this->isSameSegmentation($this->segmentation, $segmentation)
  1103.             && $this->isSameSegmentationAxis($this->segmentation, $segmentation)
  1104.         ) {
  1105.             return $this->setSegmentation($segmentation);
  1106.         }
  1107.         $this->syncSegmentationValue($segmentation);
  1108.         return $this;
  1109.     }
  1110.     /**
  1111.      * Retourne la valeur du pivot pour un axe donné (null = pseudo-axe racine, sans parent)
  1112.      */
  1113.     public function getSegmentationValueForAxis(?Segmentation $axis): ?Segmentation
  1114.     {
  1115.         foreach ($this->userSegmentations as $userSegmentation) {
  1116.             $parent = $userSegmentation->getSegmentation()->getParent();
  1117.             if ($axis === null && $parent === null) {
  1118.                 return $userSegmentation->getSegmentation();
  1119.             }
  1120.             if ($axis !== null && $parent !== null && $this->isSameSegmentation($parent, $axis)) {
  1121.                 return $userSegmentation->getSegmentation();
  1122.             }
  1123.         }
  1124.         return null;
  1125.     }
  1126.     /**
  1127.      * Ajoute la valeur dans le pivot en remplaçant celle du même axe (une valeur max par axe)
  1128.      */
  1129.     private function syncSegmentationValue(Segmentation $segmentation): void
  1130.     {
  1131.         $alreadyAssigned = false;
  1132.         foreach ($this->userSegmentations as $userSegmentation) {
  1133.             $current = $userSegmentation->getSegmentation();
  1134.             if ($this->isSameSegmentation($current, $segmentation)) {
  1135.                 $alreadyAssigned = true;
  1136.                 continue;
  1137.             }
  1138.             if ($this->isSameSegmentationAxis($current, $segmentation)) {
  1139.                 // orphanRemoval supprime la ligne du pivot au flush
  1140.                 $this->userSegmentations->removeElement($userSegmentation);
  1141.             }
  1142.         }
  1143.         if (!$alreadyAssigned) {
  1144.             $userSegmentation = (new UserSegmentation())
  1145.                 ->setUser($this)
  1146.                 ->setSegmentation($segmentation);
  1147.             $this->userSegmentations->add($userSegmentation);
  1148.         }
  1149.     }
  1150.     private function removeSegmentationValue(Segmentation $segmentation): void
  1151.     {
  1152.         foreach ($this->userSegmentations as $userSegmentation) {
  1153.             if ($this->isSameSegmentation($userSegmentation->getSegmentation(), $segmentation)) {
  1154.                 $this->userSegmentations->removeElement($userSegmentation);
  1155.             }
  1156.         }
  1157.     }
  1158.     /**
  1159.      * Comparaison par identité d'objet puis par id (les segmentations créées Ã  la volée,
  1160.      * ex. SSO, n'ont pas encore d'id au moment du set)
  1161.      */
  1162.     private function isSameSegmentation(Segmentation $a, Segmentation $b): bool
  1163.     {
  1164.         return $a === $b || ($a->getId() !== null && $a->getId() === $b->getId());
  1165.     }
  1166.     /**
  1167.      * Deux valeurs appartiennent au même axe si elles partagent le même parent ;
  1168.      * l'absence de parent est traitée comme un pseudo-axe racine unique
  1169.      * (sémantique historique de la mono-segmentation)
  1170.      */
  1171.     private function isSameSegmentationAxis(Segmentation $a, Segmentation $b): bool
  1172.     {
  1173.         $parentA = $a->getParent();
  1174.         $parentB = $b->getParent();
  1175.         if ($parentA === null || $parentB === null) {
  1176.             return $parentA === null && $parentB === null;
  1177.         }
  1178.         return $this->isSameSegmentation($parentA, $parentB);
  1179.     }
  1180.     public function getCountry(): ?string
  1181.     {
  1182.         return $this->country;
  1183.     }
  1184.     public function setCountry(?string $country): self
  1185.     {
  1186.         $this->country = $country;
  1187.         return $this;
  1188.     }
  1189.     public function getFunction(): ?string
  1190.     {
  1191.         return $this->function;
  1192.     }
  1193.     public function setFunction(?string $function): self
  1194.     {
  1195.         $this->function = $function;
  1196.         return $this;
  1197.     }
  1198.     public function getPhone(): ?string
  1199.     {
  1200.         return $this->phone;
  1201.     }
  1202.     public function setPhone(?string $phone): self
  1203.     {
  1204.         $this->phone = $phone;
  1205.         return $this;
  1206.     }
  1207.     public function getQuotas(): ?int
  1208.     {
  1209.         return $this->quotas;
  1210.     }
  1211.     public function setQuotas(?int $quotas): self
  1212.     {
  1213.         $this->quotas = $quotas;
  1214.         return $this;
  1215.     }
  1216.     public function getQuotasType(): ?string
  1217.     {
  1218.         return $this->quotasType;
  1219.     }
  1220.     public function setQuotasType(?string $quotasType): self
  1221.     {
  1222.         $this->quotasType = $quotasType;
  1223.         return $this;
  1224.     }
  1225.     /**
  1226.      * Checks the quotas of a User
  1227.      * @return bool true if ok, false if not ok
  1228.      */
  1229.     public function checkQuotas(): bool
  1230.     {
  1231.         $result = true;
  1232.         if ($this->getQuotasType() != self::QUOTA_NONE) {
  1233.             $span = self::QUOTAS_VAlUES[$this->getQuotasType()];
  1234.             $limit = new \DateTime("-$span");
  1235.             $count = 0;
  1236.             foreach ($this->getVideoEvents() as $videoEvent) {
  1237.                 if ($limit->diff($videoEvent->getCreatedAt())->invert == 0) {
  1238.                     $count += $videoEvent->getValue();
  1239.                 }
  1240.             }
  1241.             if ($count > $this->getQuotas()) {
  1242.                 $result = false;
  1243.             }
  1244.         }
  1245.         return $result;
  1246.     }
  1247.     public function getEmailUpdatedAt(): ?\DateTimeInterface
  1248.     {
  1249.         return $this->emailUpdatedAt;
  1250.     }
  1251.     public function setEmailUpdatedAt(?\DateTimeInterface $emailUpdatedAt): self
  1252.     {
  1253.         $this->emailUpdatedAt = $emailUpdatedAt;
  1254.         return $this;
  1255.     }
  1256.     public function getEmailValidatedAt(): ?\DateTimeInterface
  1257.     {
  1258.         return $this->emailValidatedAt;
  1259.     }
  1260.     public function setEmailValidatedAt(?\DateTimeInterface $emailValidatedAt): self
  1261.     {
  1262.         $this->emailValidatedAt = $emailValidatedAt;
  1263.         return $this;
  1264.     }
  1265.     /**
  1266.      * Checks if the email is validated
  1267.      * @return bool
  1268.      */
  1269.     public function isEmailValidated(): bool
  1270.     {
  1271.         return ($this->emailValidatedAt !== null);
  1272.     }
  1273.     /**
  1274.      * Updates the Company according to the status of the order
  1275.      * @return User
  1276.      * @ORM\PrePersist
  1277.      */
  1278.     public function updateCompany(): self
  1279.     {
  1280.         if ($this->company instanceof Company) {
  1281.             $this->company->setClientsCount($this->company->getClientsCount() + 1);
  1282.         }
  1283.         return $this;
  1284.     }
  1285.     public function getStatus(): ?string
  1286.     {
  1287.         return $this->status;
  1288.     }
  1289.     public function setStatus(?string $status): self
  1290.     {
  1291.         $this->status = $status;
  1292.         return $this;
  1293.     }
  1294.     public function getDeviceOs(): ?string
  1295.     {
  1296.         return $this->deviceOs;
  1297.     }
  1298.     public function setDeviceOs(?string $deviceOs): self
  1299.     {
  1300.         $this->deviceOs = $deviceOs;
  1301.         return $this;
  1302.     }
  1303.     public function getDeviceToken(): ?string
  1304.     {
  1305.         return $this->deviceToken;
  1306.     }
  1307.     public function setDeviceToken(?string $deviceToken): self
  1308.     {
  1309.         $this->deviceToken = $deviceToken;
  1310.         return $this;
  1311.     }
  1312.     public function getDeviceName(): ?string
  1313.     {
  1314.         return $this->deviceName;
  1315.     }
  1316.     public function setDeviceName(?string $deviceName): self
  1317.     {
  1318.         $this->deviceName = $deviceName;
  1319.         return $this;
  1320.     }
  1321.     public function isDeviceActive(): ?bool
  1322.     {
  1323.         return $this->deviceActive;
  1324.     }
  1325.     public function setDeviceActive(?bool $deviceActive): self
  1326.     {
  1327.         $this->deviceActive = $deviceActive;
  1328.         return $this;
  1329.     }
  1330.     public function getDeviceUpdate(): ?\DateTimeInterface
  1331.     {
  1332.         return $this->deviceUpdate;
  1333.     }
  1334.     public function setDeviceUpdate(?\DateTimeInterface $deviceUpdate): self
  1335.     {
  1336.         $this->deviceUpdate = $deviceUpdate;
  1337.         return $this;
  1338.     }
  1339.     /**
  1340.      * @return Collection<int, UserDevice>
  1341.      */
  1342.     public function getDevices(): Collection
  1343.     {
  1344.         return $this->devices;
  1345.     }
  1346.     public function addDevice(UserDevice $device): self
  1347.     {
  1348.         if (!$this->devices->contains($device)) {
  1349.             $this->devices[] = $device;
  1350.             $device->setUser($this);
  1351.         }
  1352.         return $this;
  1353.     }
  1354.     public function removeDevice(UserDevice $device): self
  1355.     {
  1356.         if ($this->devices->removeElement($device)) {
  1357.             // set the owning side to null (unless already changed)
  1358.             if ($device->getUser() === $this) {
  1359.                 $device->setUser(null);
  1360.             }
  1361.         }
  1362.         return $this;
  1363.     }
  1364.     public function getNewsletter(): ?bool
  1365.     {
  1366.         return $this->newsletter;
  1367.     }
  1368.     public function setNewsletter(?bool $newsletter): self
  1369.     {
  1370.         $this->newsletter = $newsletter;
  1371.         return $this;
  1372.     }
  1373.     public function getNewsletterDate(): ?\DateTimeInterface
  1374.     {
  1375.         return $this->newsletterDate;
  1376.     }
  1377.     public function setNewsletterDate(?\DateTimeInterface $newsletterDate): self
  1378.     {
  1379.         $this->newsletterDate = $newsletterDate;
  1380.         return $this;
  1381.     }
  1382.     /**
  1383.      * @param bool $firstLogin
  1384.      * @return User
  1385.      */
  1386.     public function setFirstLogin(bool $firstLogin): User
  1387.     {
  1388.         $this->firstLogin = $firstLogin;
  1389.         return $this;
  1390.     }
  1391.     /**
  1392.      * @return bool
  1393.      */
  1394.     public function isFirstLogin(): bool
  1395.     {
  1396.         return $this->firstLogin;
  1397.     }
  1398.     /**
  1399.      * @param bool $homeSurvey
  1400.      * @return User
  1401.      */
  1402.     public function setHomeSurvey(bool $homeSurvey): User
  1403.     {
  1404.         $this->homeSurvey = $homeSurvey;
  1405.         return $this;
  1406.     }
  1407.     /**
  1408.      * @return bool
  1409.      */
  1410.     public function isHomeSurvey(): bool
  1411.     {
  1412.         return $this->homeSurvey;
  1413.     }
  1414.     public function getDisplayTeamplayTuto(): ?bool
  1415.     {
  1416.         return $this->displayTeamplayTuto;
  1417.     }
  1418.     public function setDisplayTeamplayTuto(?bool $displayTeamplayTuto): self
  1419.     {
  1420.         $this->displayTeamplayTuto = $displayTeamplayTuto;
  1421.         return $this;
  1422.     }
  1423.     /**
  1424.      * @return Collection|Log[]
  1425.      */
  1426.     public function getLogs(): Collection
  1427.     {
  1428.         return $this->logs;
  1429.     }
  1430.     public function addLog(Log $log): self
  1431.     {
  1432.         if (!$this->logs->contains($log)) {
  1433.             $this->logs[] = $log;
  1434.             $log->setUser($this);
  1435.         }
  1436.         return $this;
  1437.     }
  1438.     public function removeLog(Log $log): self
  1439.     {
  1440.         if ($this->logs->removeElement($log)) {
  1441.             // set the owning side to null (unless already changed)
  1442.             if ($log->getUser() === $this) {
  1443.                 $log->setUser(null);
  1444.             }
  1445.         }
  1446.         return $this;
  1447.     }
  1448.     /**
  1449.      * @return Collection|Message[]
  1450.      */
  1451.     public function getMessages(): Collection
  1452.     {
  1453.         return $this->messages;
  1454.     }
  1455.     public function addMessage(Message $message): self
  1456.     {
  1457.         if (!$this->messages->contains($message)) {
  1458.             $this->messages[] = $message;
  1459.             $message->setUser($this);
  1460.         }
  1461.         return $this;
  1462.     }
  1463.     public function removeMessage(Message $message): self
  1464.     {
  1465.         if ($this->messages->removeElement($message)) {
  1466.             // set the owning side to null (unless already changed)
  1467.             if ($message->getUser() === $this) {
  1468.                 $message->setUser(null);
  1469.             }
  1470.         }
  1471.         return $this;
  1472.     }
  1473.     /**
  1474.      * @return Collection|VideoEvent[]
  1475.      */
  1476.     public function getVideoEvents(): Collection
  1477.     {
  1478.         return $this->videoEvents;
  1479.     }
  1480.     public function addVideoEvent(VideoEvent $videoEvent): self
  1481.     {
  1482.         if (!$this->videoEvents->contains($videoEvent)) {
  1483.             $this->videoEvents[] = $videoEvent;
  1484.             $videoEvent->setUser($this);
  1485.         }
  1486.         return $this;
  1487.     }
  1488.     public function removeVideoEvent(VideoEvent $videoEvent): self
  1489.     {
  1490.         if ($this->videoEvents->removeElement($videoEvent)) {
  1491.             // set the owning side to null (unless already changed)
  1492.             if ($videoEvent->getUser() === $this) {
  1493.                 $videoEvent->setUser(null);
  1494.             }
  1495.         }
  1496.         return $this;
  1497.     }
  1498.     /**
  1499.      * @return Collection|UserResponse[]
  1500.      */
  1501.     public function getUserResponses(): Collection
  1502.     {
  1503.         return $this->userResponses;
  1504.     }
  1505.     public function addUserResponse(UserResponse $userResponse): self
  1506.     {
  1507.         if (!$this->userResponses->contains($userResponse)) {
  1508.             $this->userResponses[] = $userResponse;
  1509.             $userResponse->setUser($this);
  1510.         }
  1511.         return $this;
  1512.     }
  1513.     public function removeUserResponse(UserResponse $userResponse): self
  1514.     {
  1515.         if ($this->userResponses->removeElement($userResponse)) {
  1516.             // set the owning side to null (unless already changed)
  1517.             if ($userResponse->getUser() === $this) {
  1518.                 $userResponse->setUser(null);
  1519.             }
  1520.         }
  1521.         return $this;
  1522.     }
  1523.     /**
  1524.      * @return Collection|Favorite[]
  1525.      */
  1526.     public function getTvFavorites(): Collection
  1527.     {
  1528.         return $this->tvFavorites;
  1529.     }
  1530.     public function addTvFavorite(Favorite $tvFavorite): self
  1531.     {
  1532.         if (!$this->tvFavorites->contains($tvFavorite)) {
  1533.             $this->tvFavorites[] = $tvFavorite;
  1534.         }
  1535.         return $this;
  1536.     }
  1537.     public function removeTvFavorite(Favorite $tvFavorite): self
  1538.     {
  1539.         $this->tvFavorites->removeElement($tvFavorite);
  1540.         return $this;
  1541.     }
  1542.     /**
  1543.      * @return Collection|LogEmail[]
  1544.      */
  1545.     public function getLogEmails(): Collection
  1546.     {
  1547.         return $this->logEmails;
  1548.     }
  1549.     public function addLogEmail(LogEmail $logEmail): self
  1550.     {
  1551.         if (!$this->logEmails->contains($logEmail)) {
  1552.             $this->logEmails[] = $logEmail;
  1553.             $logEmail->setUser($this);
  1554.         }
  1555.         return $this;
  1556.     }
  1557.     public function removeLogEmail(LogEmail $logEmail): self
  1558.     {
  1559.         if ($this->logEmails->removeElement($logEmail)) {
  1560.             // set the owning side to null (unless already changed)
  1561.             if ($logEmail->getUser() === $this) {
  1562.                 $logEmail->setUser(null);
  1563.             }
  1564.         }
  1565.         return $this;
  1566.     }
  1567.     /**
  1568.      * @return Collection|Playlist[]
  1569.      */
  1570.     public function getPlaylists(): Collection
  1571.     {
  1572.         return $this->playlists;
  1573.     }
  1574.     public function addPlaylist(Playlist $playlist): self
  1575.     {
  1576.         if (!$this->playlists->contains($playlist)) {
  1577.             $this->playlists[] = $playlist;
  1578.             $playlist->setUser($this);
  1579.         }
  1580.         return $this;
  1581.     }
  1582.     public function removePlaylist(Playlist $playlist): self
  1583.     {
  1584.         if ($this->playlists->removeElement($playlist)) {
  1585.             // set the owning side to null (unless already changed)
  1586.             if ($playlist->getUser() === $this) {
  1587.                 $playlist->setUser(null);
  1588.             }
  1589.         }
  1590.         return $this;
  1591.     }
  1592.     /**
  1593.      * @Groups({"user:write"})
  1594.      */
  1595.     public function setAddPlaylist(Playlist $playlist): self
  1596.     {
  1597.         if (!$this->playlists->contains($playlist)) {
  1598.             $this->playlists[] = $playlist;
  1599.             $playlist->setUser($this);
  1600.         }
  1601.         return $this;
  1602.     }
  1603.     /**
  1604.      * @Groups({"user:write"})
  1605.      */
  1606.     public function setRemovePlaylist(Playlist $playlist): self
  1607.     {
  1608.         if ($this->playlists->removeElement($playlist)) {
  1609.             // set the owning side to null (unless already changed)
  1610.             if ($playlist->getUser() === $this) {
  1611.                 $playlist->setUser(null);
  1612.             }
  1613.         }
  1614.         return $this;
  1615.     }
  1616.     /**
  1617.      * @return Collection|Objective[]
  1618.      */
  1619.     public function getObjectives(): Collection
  1620.     {
  1621.         return $this->objectives;
  1622.     }
  1623.     /**
  1624.      * @return Collection|Objective[]
  1625.      */
  1626.     public function setObjectives(Collection $objectives): self
  1627.     {
  1628.         $this->objectives = $objectives;
  1629.         return $this;
  1630.     }
  1631.     public function addObjective(Objective $objective): self
  1632.     {
  1633.         if (!$this->objectives->contains($objective)) {
  1634.             $this->objectives[] = $objective;
  1635.             $objective->addUser($this);
  1636.         }
  1637.         return $this;
  1638.     }
  1639.     public function removeObjective(Objective $objective): self
  1640.     {
  1641.         if ($this->objectives->removeElement($objective)) {
  1642.             $objective->removeUser($this);
  1643.         }
  1644.         return $this;
  1645.     }
  1646.     /**
  1647.      * @return Collection|TeamUser[]
  1648.      */
  1649.     public function getTeamUsers(): Collection
  1650.     {
  1651.         return $this->teamUsers;
  1652.     }
  1653.     public function addTeamUser(TeamUser $teamUser): self
  1654.     {
  1655.         if (!$this->teamUsers->contains($teamUser)) {
  1656.             $this->teamUsers[] = $teamUser;
  1657.             $teamUser->setUser($this);
  1658.         }
  1659.         return $this;
  1660.     }
  1661.     public function removeTeamUser(TeamUser $teamUser): self
  1662.     {
  1663.         if ($this->teamUsers->removeElement($teamUser)) {
  1664.             // set the owning side to null (unless already changed)
  1665.             if ($teamUser->getUser() === $this) {
  1666.                 $teamUser->setUser(null);
  1667.             }
  1668.         }
  1669.         return $this;
  1670.     }
  1671.     /**
  1672.      * @return Collection|TeamplayLog[]
  1673.      */
  1674.     public function getTeamplayLogs(): Collection
  1675.     {
  1676.         return $this->teamplayLogs;
  1677.     }
  1678.     public function addTeamplayLog(TeamplayLog $teamplayLog): self
  1679.     {
  1680.         if (!$this->teamplayLogs->contains($teamplayLog)) {
  1681.             $this->teamplayLogs[] = $teamplayLog;
  1682.             $teamplayLog->setUser($this);
  1683.         }
  1684.         return $this;
  1685.     }
  1686.     public function removeTeamplayLog(TeamplayLog $teamplayLog): self
  1687.     {
  1688.         if ($this->teamplayLogs->removeElement($teamplayLog)) {
  1689.             // set the owning side to null (unless already changed)
  1690.             if ($teamplayLog->getUser() === $this) {
  1691.                 $teamplayLog->setUser(null);
  1692.             }
  1693.         }
  1694.         return $this;
  1695.     }
  1696.     /**
  1697.      * @return Collection|PedometerLog[]
  1698.      */
  1699.     public function getPedometerLogs(): Collection
  1700.     {
  1701.         return $this->pedometerLogs;
  1702.     }
  1703.     public function addPedometerLog(PedometerLog $pedometerLog): self
  1704.     {
  1705.         if (!$this->pedometerLogs->contains($pedometerLog)) {
  1706.             $this->pedometerLogs[] = $pedometerLog;
  1707.             $pedometerLog->setUser($this);
  1708.         }
  1709.         return $this;
  1710.     }
  1711.     public function removePedometerLog(PedometerLog $pedometerLog): self
  1712.     {
  1713.         if ($this->pedometerLogs->removeElement($pedometerLog)) {
  1714.             // set the owning side to null (unless already changed)
  1715.             if ($pedometerLog->getUser() === $this) {
  1716.                 $pedometerLog->setUser(null);
  1717.             }
  1718.         }
  1719.         return $this;
  1720.     }
  1721.     /**
  1722.      * @return Collection<int, UserNotification>
  1723.      */
  1724.     public function getUserNotifications(): Collection
  1725.     {
  1726.         return $this->userNotifications;
  1727.     }
  1728.     public function addUserNotification(UserNotification $userNotification): self
  1729.     {
  1730.         if (!$this->userNotifications->contains($userNotification)) {
  1731.             $this->userNotifications[] = $userNotification;
  1732.             $userNotification->setUser($this);
  1733.         }
  1734.         return $this;
  1735.     }
  1736.     public function removeUserNotification(UserNotification $userNotification): self
  1737.     {
  1738.         if ($this->userNotifications->removeElement($userNotification)) {
  1739.             // set the owning side to null (unless already changed)
  1740.             if ($userNotification->getUser() === $this) {
  1741.                 $userNotification->setUser(null);
  1742.             }
  1743.         }
  1744.         return $this;
  1745.     }
  1746.     /**
  1747.      * @return Collection|AwardLog[]
  1748.      */
  1749.     public function getAwardLogs(): Collection
  1750.     {
  1751.         return $this->awardLogs;
  1752.     }
  1753.     public function addAwardLog(AwardLog $awardLog): self
  1754.     {
  1755.         if (!$this->awardLogs->contains($awardLog)) {
  1756.             $this->awardLogs[] = $awardLog;
  1757.             $awardLog->setUser($this);
  1758.         }
  1759.         return $this;
  1760.     }
  1761.     public function removeAwardLog(AwardLog $awardLog): self
  1762.     {
  1763.         if ($this->awardLogs->removeElement($awardLog)) {
  1764.             // set the owning side to null (unless already changed)
  1765.             if ($awardLog->getUser() === $this) {
  1766.                 $awardLog->setUser(null);
  1767.             }
  1768.         }
  1769.         return $this;
  1770.     }
  1771.     /**
  1772.      * @return Collection|UserVideoTimecode[]
  1773.      */
  1774.     public function getUserVideoTimecodes(): Collection
  1775.     {
  1776.         return $this->userVideoTimecodes;
  1777.     }
  1778.     public function addUserVideoTimecode(UserVideoTimecode $userVideoTimecode): self
  1779.     {
  1780.         if (!$this->userVideoTimecodes->contains($userVideoTimecode)) {
  1781.             $this->userVideoTimecodes[] = $userVideoTimecode;
  1782.             $userVideoTimecode->setUser($this);
  1783.         }
  1784.         return $this;
  1785.     }
  1786.     public function removeUserVideoTimecode(UserVideoTimecode $userVideoTimecode): self
  1787.     {
  1788.         if ($this->userVideoTimecodes->removeElement($userVideoTimecode)) {
  1789.             // set the owning side to null (unless already changed)
  1790.             if ($userVideoTimecode->getUser() === $this) {
  1791.                 $userVideoTimecode->setUser(null);
  1792.             }
  1793.         }
  1794.         return $this;
  1795.     }
  1796.     /**
  1797.      * @return Collection|Notation[]
  1798.      */
  1799.     public function getNotations(): Collection
  1800.     {
  1801.         return $this->notations;
  1802.     }
  1803.     public function addNotation(Notation $notation): self
  1804.     {
  1805.         if (!$this->notations->contains($notation)) {
  1806.             $this->notations[] = $notation;
  1807.             $notation->setUser($this);
  1808.         }
  1809.         return $this;
  1810.     }
  1811.     public function removeNotation(Notation $notation): self
  1812.     {
  1813.         if ($this->notations->removeElement($notation)) {
  1814.             // set the owning side to null (unless already changed)
  1815.             if ($notation->getUser() === $this) {
  1816.                 $notation->setUser(null);
  1817.             }
  1818.         }
  1819.         return $this;
  1820.     }
  1821.     /**
  1822.      * @return Collection|VideoLastValidate[]
  1823.      */
  1824.     public function getVideoLastValidates(): Collection
  1825.     {
  1826.         return $this->videoLastValidates;
  1827.     }
  1828.     public function addVideoLastValidate(VideoLastValidate $videoLastValidate): self
  1829.     {
  1830.         if (!$this->videoLastValidates->contains($videoLastValidate)) {
  1831.             $this->videoLastValidates[] = $videoLastValidate;
  1832.             $videoLastValidate->setUser($this);
  1833.         }
  1834.         return $this;
  1835.     }
  1836.     public function removeVideoLastValidate(VideoLastValidate $videoLastValidate): self
  1837.     {
  1838.         if ($this->videoLastValidates->removeElement($videoLastValidate)) {
  1839.             // set the owning side to null (unless already changed)
  1840.             if ($videoLastValidate->getUser() === $this) {
  1841.                 $videoLastValidate->setUser(null);
  1842.             }
  1843.         }
  1844.         return $this;
  1845.     }
  1846.     /**
  1847.      * @return Collection|VideoLastSeen[]
  1848.      */
  1849.     public function getVideoLastSeens(): Collection
  1850.     {
  1851.         return $this->videoLastSeens;
  1852.     }
  1853.     public function addVideoLastSeen(VideoLastSeen $videoLastSeen): self
  1854.     {
  1855.         if (!$this->videoLastSeens->contains($videoLastSeen)) {
  1856.             $this->videoLastSeens[] = $videoLastSeen;
  1857.             $videoLastSeen->setUser($this);
  1858.         }
  1859.         return $this;
  1860.     }
  1861.     public function removeVideoLastSeen(VideoLastSeen $videoLastSeen): self
  1862.     {
  1863.         if ($this->videoLastSeens->removeElement($videoLastSeen)) {
  1864.             // set the owning side to null (unless already changed)
  1865.             if ($videoLastSeen->getUser() === $this) {
  1866.                 $videoLastSeen->setUser(null);
  1867.             }
  1868.         }
  1869.         return $this;
  1870.     }
  1871.     /**
  1872.      * @return Collection|MoodResponse[]
  1873.      */
  1874.     public function getMoodResponses(): Collection
  1875.     {
  1876.         return $this->moodResponses;
  1877.     }
  1878.     public function addMoodResponse(MoodResponse $moodResponse): self
  1879.     {
  1880.         if (!$this->moodResponses->contains($moodResponse)) {
  1881.             $this->moodResponses[] = $moodResponse;
  1882.             $moodResponse->setUser($this);
  1883.         }
  1884.         return $this;
  1885.     }
  1886.     public function removeMoodResponse(MoodResponse $moodResponse): self
  1887.     {
  1888.         if ($this->moodResponses->removeElement($moodResponse)) {
  1889.             // set the owning side to null (unless already changed)
  1890.             if ($moodResponse->getUser() === $this) {
  1891.                 $moodResponse->setUser(null);
  1892.             }
  1893.         }
  1894.         return $this;
  1895.     }
  1896.     /**
  1897.      * @return Collection|ProgramEvent[]
  1898.      */
  1899.     public function getProgramEvents(): Collection
  1900.     {
  1901.         return $this->programEvents;
  1902.     }
  1903.     public function addProgramEvent(ProgramEvent $programEvent): self
  1904.     {
  1905.         if (!$this->programEvents->contains($programEvent)) {
  1906.             $this->programEvents[] = $programEvent;
  1907.             $programEvent->setUser($this);
  1908.         }
  1909.         return $this;
  1910.     }
  1911.     public function removeProgramEvent(ProgramEvent $programEvent): self
  1912.     {
  1913.         if ($this->programEvents->removeElement($programEvent)) {
  1914.             // set the owning side to null (unless already changed)
  1915.             if ($programEvent->getUser() === $this) {
  1916.                 $programEvent->setUser(null);
  1917.             }
  1918.         }
  1919.         return $this;
  1920.     }
  1921.     /**
  1922.      * @return Collection|DayEvent[]
  1923.      */
  1924.     public function getDayEvents(): Collection
  1925.     {
  1926.         return $this->dayEvents;
  1927.     }
  1928.     public function addDayEvent(DayEvent $dayEvent): self
  1929.     {
  1930.         if (!$this->dayEvents->contains($dayEvent)) {
  1931.             $this->dayEvents[] = $dayEvent;
  1932.             $dayEvent->setUser($this);
  1933.         }
  1934.         return $this;
  1935.     }
  1936.     public function removeDayEvent(DayEvent $dayEvent): self
  1937.     {
  1938.         if ($this->dayEvents->removeElement($dayEvent)) {
  1939.             // set the owning side to null (unless already changed)
  1940.             if ($dayEvent->getUser() === $this) {
  1941.                 $dayEvent->setUser(null);
  1942.             }
  1943.         }
  1944.         return $this;
  1945.     }
  1946.     public function getTvUser(): ?TvUser
  1947.     {
  1948.         return $this->tvUser;
  1949.     }
  1950.     public function setTvUser(?TvUser $tvUser): self
  1951.     {
  1952.         $this->tvUser = $tvUser;
  1953.         return $this;
  1954.     }
  1955.     public function isLive(): ?bool
  1956.     {
  1957.         return $this->live;
  1958.     }
  1959.     public function setLive(bool $isLive): self
  1960.     {
  1961.         $this->live = $isLive;
  1962.         return $this;
  1963.     }
  1964.     public function isTv(): ?bool
  1965.     {
  1966.         return $this->tv;
  1967.     }
  1968.     public function setTv(bool $isTv): self
  1969.     {
  1970.         $this->tv = $isTv;
  1971.         return $this;
  1972.     }
  1973.     /**
  1974.      * @return Collection<int, Chat>
  1975.      */
  1976.     public function getChats(): Collection
  1977.     {
  1978.         return $this->chats;
  1979.     }
  1980.     public function addChat(Chat $chat): self
  1981.     {
  1982.         if (!$this->chats->contains($chat)) {
  1983.             $this->chats[] = $chat;
  1984.         }
  1985.         return $this;
  1986.     }
  1987.     public function removeChat(Chat $chat): self
  1988.     {
  1989.         $this->chats->removeElement($chat);
  1990.         return $this;
  1991.     }
  1992.     /**
  1993.      * @return Collection<int, Invoice>
  1994.      */
  1995.     public function getInvoices(): Collection
  1996.     {
  1997.         return $this->invoices;
  1998.     }
  1999.     public function addInvoice(Invoice $invoice): self
  2000.     {
  2001.         if (!$this->invoices->contains($invoice)) {
  2002.             $this->invoices->add($invoice);
  2003.             $invoice->setUser($this);
  2004.         }
  2005.         return $this;
  2006.     }
  2007.     public function removeInvoice(Invoice $invoice): self
  2008.     {
  2009.         if ($this->invoices->removeElement($invoice)) {
  2010.             // set the owning side to null (unless already changed)
  2011.             if ($invoice->getUser() === $this) {
  2012.                 $invoice->setUser(null);
  2013.             }
  2014.         }
  2015.         return $this;
  2016.     }
  2017.     public function getNotificationPreference(): ?NotificationPreference
  2018.     {
  2019.         return $this->notificationPreference;
  2020.     }
  2021.     public function setNotificationPreference(NotificationPreference $notificationPreference): static
  2022.     {
  2023.         // set the owning side of the relation if necessary
  2024.         if ($notificationPreference->getUser() !== $this) {
  2025.             $notificationPreference->setUser($this);
  2026.         }
  2027.         $this->notificationPreference = $notificationPreference;
  2028.         return $this;
  2029.     }
  2030.     public function getStravaProfile(): ?StravaProfile
  2031.     {
  2032.         return $this->stravaProfile;
  2033.     }
  2034.     public function setStravaProfile(?StravaProfile $stravaProfile): self
  2035.     {
  2036.         if ($stravaProfile !== null && $stravaProfile->getUser() !== $this) {
  2037.             $stravaProfile->setUser($this);
  2038.         }
  2039.         $this->stravaProfile = $stravaProfile;
  2040.         return $this;
  2041.     }
  2042. }