src/Entity/User.php line 124

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