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 UserInterfacePasswordAuthenticatedUserInterfaceSamlUserInterface
  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.      * @ORM\Column(type="string", length=255, nullable=true, options={"default": "FR"})
  339.      * @Groups({"user:read:country"})
  340.      */
  341.     private $country;
  342.     /**
  343.      * @ORM\Column(name="`function`", type="string", length=255, nullable=true)
  344.      * @Groups({"user:read:function", "user:read", "user:write", "company:read", "company:write", "export_csv", "manager_dashboard"})
  345.      */
  346.     private $function;
  347.     /**
  348.      * @ORM\Column(type="string", length=255, nullable=true)
  349.      * @Groups({"user:read:phone", "user:read", "user:write", "company:read", "company:write", "export_csv", "manager_dashboard"})
  350.      * @Assert\Length(min=8, max=20, minMessage="phone.min", maxMessage="phone.max")
  351.      */
  352.     private $phone;
  353.     /**
  354.      * @ORM\Column(type="string", length=255, nullable=true)
  355.      * @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"})
  356.      */
  357.     private $username;
  358.     /**
  359.      * @ORM\Column(type="integer", options={"default": "-1"})
  360.      * @Groups({"user:read:quotas", "user:read", "user:write", "user:read:export_csv"})
  361.      */
  362.     private $quotas = -1;
  363.     /**
  364.      * @ORM\Column(type="string", length=255, options={"default": "unset"})
  365.      * @Groups({"user:read:quotasType", "user:read", "user:write", "user:read:export_csv"})
  366.      */
  367.     private $quotasType self::QUOTA_NONE;
  368.     /**
  369.      * @ORM\Column(type="datetime", nullable=true)
  370.      * @Gedmo\Timestampable(on="change", field="email")
  371.      */
  372.     private $emailUpdatedAt;
  373.     /**
  374.      * @ORM\Column(type="datetime", nullable=true)
  375.      */
  376.     private $emailValidatedAt;
  377.     /**
  378.      * @ORM\Column(type="string", length=255, nullable=true)
  379.      * @Groups({"user:read:status", "user:read", "company:read", "user:read:export_csv", "client:read"})
  380.      * @Assert\Choice(choices=self::STATUSES)
  381.      */
  382.     private $status self::STATUS_ACTIVE;
  383.     /**
  384.      * @ORM\Column(type="string", length=255, nullable=true)
  385.      * @Groups({"user:read:deviceOs", "user:read", "user:write"})
  386.      */
  387.     private $deviceOs;
  388.     /**
  389.      * @ORM\Column(type="text", nullable=true)
  390.      * @Groups({"user:read:deviceToken", "user:read", "user:write"})
  391.      */
  392.     private $deviceToken;
  393.     /**
  394.      * @ORM\Column(type="string", length=255, nullable=true)
  395.      * @Groups({"user:read:deviceName", "user:read", "user:write"})
  396.      */
  397.     private $deviceName;
  398.     /**
  399.      * @ORM\Column(type="boolean", nullable=true, options={"default": 1})
  400.      * @Groups({"user:read:deviceActive", "user:read", "user:write"})
  401.      */
  402.     private $deviceActive true;
  403.     /**
  404.      * @ORM\Column(type="datetime", nullable=true)
  405.      * @Gedmo\Timestampable(on="change", field={"deviceOs", "deviceToken", "deviceName", "deviceActive"})
  406.      * @Groups({"user:read:deviceUpdate", "user:read", "user:write"})
  407.      */
  408.     private $deviceUpdate;
  409.     /**
  410.      * @ORM\OneToMany(targetEntity=UserDevice::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  411.      */
  412.     private $devices;
  413.     /**
  414.      * @ORM\Column(type="boolean", options={"default": "0"})
  415.      * @Groups({"user:read:newsletter", "user:read", "company:read", "user:write", "client:read", "client:write"})
  416.      */
  417.     private $newsletter false;
  418.     /**
  419.      * @ORM\Column(type="datetime", nullable=true)
  420.      * @Groups({"user:read:newsletterDate", "user:read", "company:read"})
  421.      * @Gedmo\Timestampable(on="change", field="newsletter", value=true)
  422.      */
  423.     private $newsletterDate;
  424.     /**
  425.      * @ORM\Column(type="boolean", options={"default": "1"})
  426.      * @Groups({"user:read:firstLogin", "user:read", "company:read", "user:write", "client:read", "client:write"})
  427.      */
  428.     private $firstLogin true;
  429.     /**
  430.      * @ORM\Column(type="boolean", options={"default": "1"})
  431.      * @Groups({"user:read:homeSurvey", "user:read", "company:read", "user:write", "client:read", "client:write"})
  432.      */
  433.     private $homeSurvey true;
  434.     /**
  435.      * @ORM\Column(type="boolean", nullable=true, options={"default": "1"})
  436.      * @Groups({"user:read:displayTeamplayTuto", "user:read", "user:write", "user:read:tuto_only", "client:read", "client:write"})
  437.      */
  438.     private $displayTeamplayTuto true;
  439.     /**
  440.      * @ORM\OneToMany(targetEntity=Log::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  441.      */
  442.     private $logs;
  443.     /**
  444.      * Sent messages by the user to web admins
  445.      * @ORM\OneToMany(targetEntity=Message::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  446.      */
  447.     private $messages;
  448.     /**
  449.      * @ORM\OneToMany(targetEntity=VideoEvent::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  450.      */
  451.     private $videoEvents;
  452.     /**
  453.      * @ORM\OneToMany(targetEntity=UserResponse::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  454.      */
  455.     private $userResponses;
  456.     /**
  457.      * @ORM\OneToMany(targetEntity=Favorite::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  458.      * @Groups({"user:read:tvFavorites"})
  459.      * @ApiSubresource(maxDepth=1)
  460.      */
  461.     private $tvFavorites;
  462.     /**
  463.      * @ORM\OneToMany(targetEntity=LogEmail::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  464.      */
  465.     private $logEmails;
  466.     /**
  467.      * @ORM\OneToMany(targetEntity=Playlist::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  468.      */
  469.     private $playlists;
  470.     /**
  471.      * @ORM\ManyToMany(targetEntity=Objective::class, mappedBy="users")
  472.      * @Groups({"user:read", "user:write"})
  473.      */
  474.     private $objectives;
  475.     /**
  476.      * @ORM\OneToMany(targetEntity=TeamUser::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  477.      */
  478.     private $teamUsers;
  479.     /**
  480.      * @ORM\OneToMany(targetEntity=TeamplayLog::class, mappedBy="user", orphanRemoval=true, cascade={"refresh", "remove"})
  481.      */
  482.     private $teamplayLogs;
  483.     /**
  484.      * @ORM\OneToMany(targetEntity=PedometerLog::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  485.      */
  486.     private $pedometerLogs;
  487.     /**
  488.      * @ORM\OneToMany(targetEntity=UserNotification::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  489.      */
  490.     private $userNotifications;
  491.     /**
  492.      * @ORM\OneToMany(targetEntity=AwardLog::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  493.      */
  494.     private $awardLogs;
  495.     /**
  496.      * @ORM\OneToMany(targetEntity=UserVideoTimecode::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  497.      */
  498.     private $userVideoTimecodes;
  499.     /**
  500.      * @ORM\OneToMany(targetEntity=Notation::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  501.      */
  502.     private $notations;
  503.     /**
  504.      * @ORM\OneToMany(targetEntity=VideoLastValidate::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  505.      */
  506.     private $videoLastValidates;
  507.     /**
  508.      * @ORM\OneToMany(targetEntity=VideoLastSeen::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  509.      */
  510.     private $videoLastSeens;
  511.     /**
  512.      * @ORM\OneToMany(targetEntity=MoodResponse::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  513.      */
  514.     private $moodResponses;
  515.     /**
  516.      * @ORM\OneToMany(targetEntity=ProgramEvent::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  517.      */
  518.     private $programEvents;
  519.     /**
  520.      * @ORM\OneToMany(targetEntity=DayEvent::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  521.      */
  522.     private $dayEvents;
  523.     /**
  524.      * @ORM\OneToOne(targetEntity=TvUser::class, mappedBy="user", cascade={"persist", "refresh","remove"})
  525.      */
  526.     private $tvUser;
  527.     /**
  528.      * @ORM\Column(type="boolean", options={"default": "1"})
  529.      * @Groups({"user:read:live", "user:read", "user:write",  "user_favorite:read", "client:read"})
  530.      */
  531.     private $live true;
  532.     /**
  533.      * @ORM\Column(type="boolean", options={"default": "1"})
  534.      * @Groups({"user:read:tv", "user:read", "user:write",  "user_favorite:read", "client:read"})
  535.      */
  536.     private $tv true;
  537.     /**
  538.      *  
  539.      * @ORM\ManyToMany(targetEntity=Chat::class, inversedBy="users")
  540.      */
  541.     private $chats;
  542.     /**
  543.      * @var bool
  544.      */
  545.     public $isPopulated false;
  546.     /**
  547.      * @ORM\OneToMany(targetEntity=Invoice::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true) 
  548.      */
  549.     private $invoices;
  550.     /**
  551.      * @ORM\OneToOne(targetEntity=NotificationPreference::class, mappedBy="user", cascade={"persist","remove"})
  552.      */
  553.     private $notificationPreference null;
  554.     public function __construct()
  555.     {
  556.         $this->roles[] = self::ROLE_USER;
  557.         $this->documents = new ArrayCollection();
  558.         $this->marketplaceReservations = new ArrayCollection();
  559.         $this->favorites = new ArrayCollection();
  560.         $this->devices = new ArrayCollection();
  561.         $this->logs = new ArrayCollection();
  562.         $this->messages = new ArrayCollection();
  563.         $this->videoEvents = new ArrayCollection();
  564.         $this->userResponses = new ArrayCollection();
  565.         $this->tvFavorites = new ArrayCollection();
  566.         $this->logEmails = new ArrayCollection();
  567.         $this->playlists = new ArrayCollection();
  568.         $this->objectives = new ArrayCollection();
  569.         $this->teamUsers = new ArrayCollection();
  570.         $this->teamplayLogs = new ArrayCollection();
  571.         $this->pedometerLogs = new ArrayCollection();
  572.         $this->userNotifications = new ArrayCollection();
  573.         $this->awardLogs = new ArrayCollection();
  574.         $this->userVideoTimecodes = new ArrayCollection();
  575.         $this->notations = new ArrayCollection();
  576.         $this->videoLastValidates = new ArrayCollection();
  577.         $this->videoLastSeens = new ArrayCollection();
  578.         $this->moodResponses = new ArrayCollection();
  579.         $this->programEvents = new ArrayCollection();
  580.         $this->dayEvents = new ArrayCollection();
  581.         $this->chats = new ArrayCollection();
  582.         $this->invoices = new ArrayCollection();
  583.     }
  584.     public function getId(): ?int
  585.     {
  586.         return $this->id;
  587.     }
  588.     public function getEmail(): ?string
  589.     {
  590.         return $this->email;
  591.     }
  592.     public function setEmail(string $email): self
  593.     {
  594.         $this->email $email;
  595.         return $this;
  596.     }
  597.     /**
  598.      * A visual identifier that represents this user.
  599.      *
  600.      * @see UserInterface
  601.      */
  602.     public function getUserIdentifier(): string
  603.     {
  604.         return (string)$this->email;
  605.     }
  606.     public function getUsername(): ?string
  607.     {
  608.         return $this->username;
  609.     }
  610.     public function setUsername(?string $username): self
  611.     {
  612.         $this->username $username;
  613.         return $this;
  614.     }
  615.     /**
  616.      * @see UserInterface
  617.      */
  618.     public function getRoles(): array
  619.     {
  620.         $roles $this->roles;
  621.         // guarantee every user at least has ROLE_USER
  622.         $roles[] = self::ROLE_USER;
  623.         if ($this->isTv()) {
  624.             $roles[] = self::ROLE_TV;
  625.         }
  626.         if ($this->isLive()) {
  627.             $roles[] = self::ROLE_LIVE;
  628.         }
  629.         return array_unique($roles);
  630.     }
  631.     /**
  632.      * @param string $role
  633.      * @return bool
  634.      */
  635.     public function hasRole(string $role): bool
  636.     {
  637.         return in_array($role$this->roles);
  638.     }
  639.     /**
  640.      * @see UserInterface
  641.      */
  642.     public function addRole(string $role): self
  643.     {
  644.         if (!in_array($role$this->roles)) {
  645.             $this->roles[] = $role;
  646.         }
  647.         return $this;
  648.     }
  649.     /**
  650.      * @see UserInterface
  651.      */
  652.     public function removeRole(string $role): self
  653.     {
  654.         if (in_array($role$this->roles)) {
  655.             foreach ($this->roles as $key => $item) {
  656.                 if ($item === $role) {
  657.                     unset($this->roles[$key]);
  658.                 }
  659.             }
  660.             $this->roles array_values($this->roles);
  661.         }
  662.         return $this;
  663.     }
  664.     public function setRoles(array $roles): self
  665.     {
  666.         $this->roles $roles;
  667.         return $this;
  668.     }
  669.     /**
  670.      * @see PasswordAuthenticatedUserInterface
  671.      */
  672.     public function getPassword(): ?string
  673.     {
  674.         return $this->password;
  675.     }
  676.     /**
  677.      * This setter also checks if the password has changed it will rehash it
  678.      * @param string|null $password New password
  679.      * @param bool $hash Forces rehash of password
  680.      * @return $this
  681.      */
  682.     public function setPassword(?string $passwordbool $hash false): self
  683.     {
  684.         if (!empty($password) && ($this->password !== $password || $hash)) {
  685.             $this->_hashPwd true;
  686.         }
  687.         if (!empty($password)) {
  688.             $this->password $password;
  689.         }
  690.         return $this;
  691.     }
  692.     /**
  693.      * If persisted this password will be encoded into the password field
  694.      * @param ?string $oldPassword
  695.      * @return User
  696.      */
  697.     public function setOldPassword(?string $oldPassword): User
  698.     {
  699.         $this->oldPassword $oldPassword;
  700.         return $this;
  701.     }
  702.     /**
  703.      * @return string
  704.      */
  705.     public function getOldPassword(): ?string
  706.     {
  707.         return $this->oldPassword;
  708.     }
  709.     /**
  710.      * If persisted this password will be encoded into the password field
  711.      * @param string $password
  712.      * @return User
  713.      */
  714.     public function setPlainPassword(string $password): User
  715.     {
  716.         $this->plainPassword $password;
  717.         return $this;
  718.     }
  719.     /**
  720.      * @return string
  721.      */
  722.     public function getPlainPassword(): ?string
  723.     {
  724.         return $this->plainPassword;
  725.     }
  726.     /**
  727.      * @return string|null
  728.      */
  729.     public function getPasswordConfirm(): ?string
  730.     {
  731.         return $this->passwordConfirm;
  732.     }
  733.     /**
  734.      * @param string|null $passwordConfirm
  735.      * @return User
  736.      */
  737.     public function setPasswordConfirm(?string $passwordConfirm): User
  738.     {
  739.         $this->passwordConfirm $passwordConfirm;
  740.         return $this;
  741.     }
  742.     /**
  743.      * Returning a salt is only needed, if you are not using a modern
  744.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  745.      *
  746.      * @see UserInterface
  747.      */
  748.     public function getSalt(): ?string
  749.     {
  750.         return null;
  751.     }
  752.     /**
  753.      * @see UserInterface
  754.      */
  755.     public function eraseCredentials()
  756.     {
  757.         // If you store any temporary, sensitive data on the user, clear it here
  758.         $this->plainPassword null;
  759.     }
  760.     public function getCreatedAt(): ?\DateTime
  761.     {
  762.         return $this->createdAt;
  763.     }
  764.     public function setCreatedAt(\DateTime $createdAt): self
  765.     {
  766.         $this->createdAt $createdAt;
  767.         return $this;
  768.     }
  769.     public function getUpdatedAt(): ?\DateTime
  770.     {
  771.         return $this->updatedAt;
  772.     }
  773.     public function setUpdatedAt(\DateTime $updatedAt): self
  774.     {
  775.         $this->updatedAt $updatedAt;
  776.         return $this;
  777.     }
  778.     public function getLastLogin(): ?\DateTimeInterface
  779.     {
  780.         return $this->lastLogin;
  781.     }
  782.     public function setLastLogin(?\DateTimeInterface $lastLogin): self
  783.     {
  784.         $this->lastLogin $lastLogin;
  785.         return $this;
  786.     }
  787.     public function getName(): ?string
  788.     {
  789.         return $this->name;
  790.     }
  791.     public function setName(?string $name): self
  792.     {
  793.         $this->name $name;
  794.         return $this;
  795.     }
  796.     public function getCategory(): ?string
  797.     {
  798.         return $this->category;
  799.     }
  800.     public function setCategory(string $category): self
  801.     {
  802.         $this->category $category;
  803.         return $this;
  804.     }
  805.     public function getActive(): ?bool
  806.     {
  807.         return $this->active;
  808.     }
  809.     public function isActive(): ?bool
  810.     {
  811.         return $this->active;
  812.     }
  813.     public function setActive(bool $active): self
  814.     {
  815.         $this->active $active;
  816.         if ($this->active) {
  817.             $this->status self::STATUS_ACTIVE;
  818.         } else {
  819.             $this->status self::STATUS_SUSPENDED;
  820.         }
  821.         return $this;
  822.     }
  823.     public function getBanStart(): ?\DateTimeInterface
  824.     {
  825.         return $this->banStart;
  826.     }
  827.     public function setBanStart(?\DateTimeInterface $banStart): self
  828.     {
  829.         $this->banStart $banStart;
  830.         return $this;
  831.     }
  832.     public function getBanEnd(): ?\DateTimeInterface
  833.     {
  834.         return $this->banEnd;
  835.     }
  836.     public function setBanEnd(?\DateTimeInterface $banEnd): self
  837.     {
  838.         $this->banEnd $banEnd;
  839.         return $this;
  840.     }
  841.     public function getResetToken(): ?string
  842.     {
  843.         return $this->resetToken;
  844.     }
  845.     public function setResetToken(?string $resetToken): self
  846.     {
  847.         $this->resetToken $resetToken;
  848.         return $this;
  849.     }
  850.     public function getSpecialist(): ?Specialist
  851.     {
  852.         return $this->specialist;
  853.     }
  854.     public function setSpecialist(Specialist $specialist): self
  855.     {
  856.         // set the owning side of the relation if necessary
  857.         if ($specialist->getUser() !== $this) {
  858.             $specialist->setUser($this);
  859.         }
  860.         $this->specialist $specialist;
  861.         return $this;
  862.     }
  863.     public function getCompany(): ?Company
  864.     {
  865.         return $this->company;
  866.     }
  867.     public function setCompany(?Company $company): self
  868.     {
  869.         $this->company $company;
  870.         return $this;
  871.     }
  872.     public function getClient(): ?Client
  873.     {
  874.         return $this->client;
  875.     }
  876.     public function setClient(Client $client): self
  877.     {
  878.         // set the owning side of the relation if necessary
  879.         if ($client->getUser() !== $this) {
  880.             $client->setUser($this);
  881.         }
  882.         $this->client $client;
  883.         return $this;
  884.     }
  885.     /**
  886.      * @return bool
  887.      */
  888.     public function isHashPwd(): bool
  889.     {
  890.         return $this->_hashPwd;
  891.     }
  892.     /**
  893.      * @return string
  894.      */
  895.     public function __toString()
  896.     {
  897.         return $this->name;
  898.     }
  899.     /**
  900.      * @ORM\PrePersist()
  901.      */
  902.     public function updateName()
  903.     {
  904.         if ($this->company instanceof Company) {
  905.             $this->name $this->company->getName();
  906.         } elseif ($this->specialist instanceof Specialist) {
  907.             $this->name = (string)$this->specialist;
  908.         } elseif ($this->client instanceof Client) {
  909.             $this->name = (string)$this->client;
  910.         }
  911.     }
  912.     /**
  913.      * @param string|null $token
  914.      * @return User
  915.      */
  916.     public function setToken(?string $token): User
  917.     {
  918.         $this->token $token;
  919.         return $this;
  920.     }
  921.     /**
  922.      * @return string|null
  923.      */
  924.     public function getToken(): ?string
  925.     {
  926.         return $this->token;
  927.     }
  928.     public function setSamlAttributes(array $attributes)
  929.     {
  930.         $this->token $attributes['sessionIndex'];
  931.         $data = [];
  932.         foreach ($attributes as $key => $value) {
  933.             $data[ToolsService::toCamelCase($key)] = $value;
  934.         }
  935.         if (!empty($data['email'])) {
  936.             if (is_array($data['email'])) $this->email $data['email'][0];
  937.             elseif (is_string($data['email'])) $this->email $data['email'];
  938.         }
  939.         if (!empty($data['firstName'])) {
  940.             if (is_array($data['firstName'])) $this->firstName $data['firstName'][0];
  941.             elseif (is_string($data['firstName'])) $this->firstName $data['firstName'];
  942.         }
  943.         if (!empty($data['lastName'])) {
  944.             if (is_array($data['lastName'])) $this->lastName $data['lastName'][0];
  945.             elseif (is_string($data['lastName'])) $this->lastName $data['lastName'];
  946.         }
  947.         if (!empty($data['country'])) {
  948.             if (is_array($data['country'])) $this->country $data['country'][0];
  949.             elseif (is_string($data['country'])) $this->country $data['country'];
  950.         }
  951.     }
  952.     /**
  953.      * @return Collection<int, Document>
  954.      */
  955.     public function getDocuments(): Collection
  956.     {
  957.         return $this->documents;
  958.     }
  959.     public function addDocument(Document $document): self
  960.     {
  961.         if (!$this->documents->contains($document)) {
  962.             $this->documents[] = $document;
  963.             $document->setOwner($this);
  964.         }
  965.         return $this;
  966.     }
  967.     public function removeDocument(Document $document): self
  968.     {
  969.         if ($this->documents->removeElement($document)) {
  970.             // set the owning side to null (unless already changed)
  971.             if ($document->getOwner() === $this) {
  972.                 $document->setOwner(null);
  973.             }
  974.         }
  975.         return $this;
  976.     }
  977.     /**
  978.      * @return Collection<int, MarketplaceReservation>
  979.      */
  980.     public function getMarketplaceReservations(): Collection
  981.     {
  982.         return $this->marketplaceReservations;
  983.     }
  984.     public function addMarketplaceReservation(MarketplaceReservation $marketplaceReservation): self
  985.     {
  986.         if (!$this->marketplaceReservations->contains($marketplaceReservation)) {
  987.             $this->marketplaceReservations[] = $marketplaceReservation;
  988.             $marketplaceReservation->setUser($this);
  989.         }
  990.         return $this;
  991.     }
  992.     public function removeMarketplaceReservation(MarketplaceReservation $marketplaceReservation): self
  993.     {
  994.         if ($this->marketplaceReservations->removeElement($marketplaceReservation)) {
  995.             // set the owning side to null (unless already changed)
  996.             if ($marketplaceReservation->getUser() === $this) {
  997.                 $marketplaceReservation->setUser(null);
  998.             }
  999.         }
  1000.         return $this;
  1001.     }
  1002.     public function getFirstName(): ?string
  1003.     {
  1004.         return $this->firstName;
  1005.     }
  1006.     public function setFirstName(?string $firstName): self
  1007.     {
  1008.         $this->firstName $firstName;
  1009.         $name $this->firstName;
  1010.         if (!empty($this->lastName)) {
  1011.             $name .= " " $this->lastName;
  1012.         }
  1013.         $this->setName($name);
  1014.         return $this;
  1015.     }
  1016.     public function getLastName(): ?string
  1017.     {
  1018.         return $this->lastName;
  1019.     }
  1020.     public function setLastName(?string $lastName): self
  1021.     {
  1022.         $this->lastName $lastName;
  1023.         $name $this->firstName;
  1024.         if (!empty($this->lastName)) {
  1025.             $name .= " " $this->lastName;
  1026.         }
  1027.         $this->setName($name);
  1028.         return $this;
  1029.     }
  1030.     /**
  1031.      * @return Collection<int, UserFavorite>
  1032.      */
  1033.     public function getFavorites(): Collection
  1034.     {
  1035.         return $this->favorites;
  1036.     }
  1037.     public function addFavorite(UserFavorite $favorite): self
  1038.     {
  1039.         if (!$this->favorites->contains($favorite)) {
  1040.             $this->favorites[] = $favorite;
  1041.             $favorite->setUser($this);
  1042.         }
  1043.         return $this;
  1044.     }
  1045.     public function removeFavorite(UserFavorite $favorite): self
  1046.     {
  1047.         if ($this->favorites->removeElement($favorite)) {
  1048.             // set the owning side to null (unless already changed)
  1049.             if ($favorite->getUser() === $this) {
  1050.                 $favorite->setUser(null);
  1051.             }
  1052.         }
  1053.         return $this;
  1054.     }
  1055.     public function getSegmentation(): ?Segmentation
  1056.     {
  1057.         return $this->segmentation;
  1058.     }
  1059.     public function setSegmentation(?Segmentation $segmentation): self
  1060.     {
  1061.         $this->segmentation $segmentation;
  1062.         if ($this->getClient()) {
  1063.             $this->getClient()->setSegmentation($segmentation);
  1064.         }
  1065.         return $this;
  1066.     }
  1067.     public function getCountry(): ?string
  1068.     {
  1069.         return $this->country;
  1070.     }
  1071.     public function setCountry(?string $country): self
  1072.     {
  1073.         $this->country $country;
  1074.         return $this;
  1075.     }
  1076.     public function getFunction(): ?string
  1077.     {
  1078.         return $this->function;
  1079.     }
  1080.     public function setFunction(?string $function): self
  1081.     {
  1082.         $this->function $function;
  1083.         return $this;
  1084.     }
  1085.     public function getPhone(): ?string
  1086.     {
  1087.         return $this->phone;
  1088.     }
  1089.     public function setPhone(?string $phone): self
  1090.     {
  1091.         $this->phone $phone;
  1092.         return $this;
  1093.     }
  1094.     public function getQuotas(): ?int
  1095.     {
  1096.         return $this->quotas;
  1097.     }
  1098.     public function setQuotas(?int $quotas): self
  1099.     {
  1100.         $this->quotas $quotas;
  1101.         return $this;
  1102.     }
  1103.     public function getQuotasType(): ?string
  1104.     {
  1105.         return $this->quotasType;
  1106.     }
  1107.     public function setQuotasType(?string $quotasType): self
  1108.     {
  1109.         $this->quotasType $quotasType;
  1110.         return $this;
  1111.     }
  1112.     /**
  1113.      * Checks the quotas of a User
  1114.      * @return bool true if ok, false if not ok
  1115.      */
  1116.     public function checkQuotas(): bool
  1117.     {
  1118.         $result true;
  1119.         if ($this->getQuotasType() != self::QUOTA_NONE) {
  1120.             $span self::QUOTAS_VAlUES[$this->getQuotasType()];
  1121.             $limit = new \DateTime("-$span");
  1122.             $count 0;
  1123.             foreach ($this->getVideoEvents() as $videoEvent) {
  1124.                 if ($limit->diff($videoEvent->getCreatedAt())->invert == 0) {
  1125.                     $count += $videoEvent->getValue();
  1126.                 }
  1127.             }
  1128.             if ($count $this->getQuotas()) {
  1129.                 $result false;
  1130.             }
  1131.         }
  1132.         return $result;
  1133.     }
  1134.     public function getEmailUpdatedAt(): ?\DateTimeInterface
  1135.     {
  1136.         return $this->emailUpdatedAt;
  1137.     }
  1138.     public function setEmailUpdatedAt(?\DateTimeInterface $emailUpdatedAt): self
  1139.     {
  1140.         $this->emailUpdatedAt $emailUpdatedAt;
  1141.         return $this;
  1142.     }
  1143.     public function getEmailValidatedAt(): ?\DateTimeInterface
  1144.     {
  1145.         return $this->emailValidatedAt;
  1146.     }
  1147.     public function setEmailValidatedAt(?\DateTimeInterface $emailValidatedAt): self
  1148.     {
  1149.         $this->emailValidatedAt $emailValidatedAt;
  1150.         return $this;
  1151.     }
  1152.     /**
  1153.      * Checks if the email is validated
  1154.      * @return bool
  1155.      */
  1156.     public function isEmailValidated(): bool
  1157.     {
  1158.         return ($this->emailValidatedAt !== null);
  1159.     }
  1160.     /**
  1161.      * Updates the Company according to the status of the order
  1162.      * @return User
  1163.      * @ORM\PrePersist
  1164.      */
  1165.     public function updateCompany(): self
  1166.     {
  1167.         if ($this->company instanceof Company) {
  1168.             $this->company->setClientsCount($this->company->getClientsCount() + 1);
  1169.         }
  1170.         return $this;
  1171.     }
  1172.     public function getStatus(): ?string
  1173.     {
  1174.         return $this->status;
  1175.     }
  1176.     public function setStatus(?string $status): self
  1177.     {
  1178.         $this->status $status;
  1179.         return $this;
  1180.     }
  1181.     public function getDeviceOs(): ?string
  1182.     {
  1183.         return $this->deviceOs;
  1184.     }
  1185.     public function setDeviceOs(?string $deviceOs): self
  1186.     {
  1187.         $this->deviceOs $deviceOs;
  1188.         return $this;
  1189.     }
  1190.     public function getDeviceToken(): ?string
  1191.     {
  1192.         return $this->deviceToken;
  1193.     }
  1194.     public function setDeviceToken(?string $deviceToken): self
  1195.     {
  1196.         $this->deviceToken $deviceToken;
  1197.         return $this;
  1198.     }
  1199.     public function getDeviceName(): ?string
  1200.     {
  1201.         return $this->deviceName;
  1202.     }
  1203.     public function setDeviceName(?string $deviceName): self
  1204.     {
  1205.         $this->deviceName $deviceName;
  1206.         return $this;
  1207.     }
  1208.     public function isDeviceActive(): ?bool
  1209.     {
  1210.         return $this->deviceActive;
  1211.     }
  1212.     public function setDeviceActive(?bool $deviceActive): self
  1213.     {
  1214.         $this->deviceActive $deviceActive;
  1215.         return $this;
  1216.     }
  1217.     public function getDeviceUpdate(): ?\DateTimeInterface
  1218.     {
  1219.         return $this->deviceUpdate;
  1220.     }
  1221.     public function setDeviceUpdate(?\DateTimeInterface $deviceUpdate): self
  1222.     {
  1223.         $this->deviceUpdate $deviceUpdate;
  1224.         return $this;
  1225.     }
  1226.     /**
  1227.      * @return Collection<int, UserDevice>
  1228.      */
  1229.     public function getDevices(): Collection
  1230.     {
  1231.         return $this->devices;
  1232.     }
  1233.     public function addDevice(UserDevice $device): self
  1234.     {
  1235.         if (!$this->devices->contains($device)) {
  1236.             $this->devices[] = $device;
  1237.             $device->setUser($this);
  1238.         }
  1239.         return $this;
  1240.     }
  1241.     public function removeDevice(UserDevice $device): self
  1242.     {
  1243.         if ($this->devices->removeElement($device)) {
  1244.             // set the owning side to null (unless already changed)
  1245.             if ($device->getUser() === $this) {
  1246.                 $device->setUser(null);
  1247.             }
  1248.         }
  1249.         return $this;
  1250.     }
  1251.     public function getNewsletter(): ?bool
  1252.     {
  1253.         return $this->newsletter;
  1254.     }
  1255.     public function setNewsletter(?bool $newsletter): self
  1256.     {
  1257.         $this->newsletter $newsletter;
  1258.         return $this;
  1259.     }
  1260.     public function getNewsletterDate(): ?\DateTimeInterface
  1261.     {
  1262.         return $this->newsletterDate;
  1263.     }
  1264.     public function setNewsletterDate(?\DateTimeInterface $newsletterDate): self
  1265.     {
  1266.         $this->newsletterDate $newsletterDate;
  1267.         return $this;
  1268.     }
  1269.     /**
  1270.      * @param bool $firstLogin
  1271.      * @return User
  1272.      */
  1273.     public function setFirstLogin(bool $firstLogin): User
  1274.     {
  1275.         $this->firstLogin $firstLogin;
  1276.         return $this;
  1277.     }
  1278.     /**
  1279.      * @return bool
  1280.      */
  1281.     public function isFirstLogin(): bool
  1282.     {
  1283.         return $this->firstLogin;
  1284.     }
  1285.     /**
  1286.      * @param bool $homeSurvey
  1287.      * @return User
  1288.      */
  1289.     public function setHomeSurvey(bool $homeSurvey): User
  1290.     {
  1291.         $this->homeSurvey $homeSurvey;
  1292.         return $this;
  1293.     }
  1294.     /**
  1295.      * @return bool
  1296.      */
  1297.     public function isHomeSurvey(): bool
  1298.     {
  1299.         return $this->homeSurvey;
  1300.     }
  1301.     public function getDisplayTeamplayTuto(): ?bool
  1302.     {
  1303.         return $this->displayTeamplayTuto;
  1304.     }
  1305.     public function setDisplayTeamplayTuto(?bool $displayTeamplayTuto): self
  1306.     {
  1307.         $this->displayTeamplayTuto $displayTeamplayTuto;
  1308.         return $this;
  1309.     }
  1310.     /**
  1311.      * @return Collection|Log[]
  1312.      */
  1313.     public function getLogs(): Collection
  1314.     {
  1315.         return $this->logs;
  1316.     }
  1317.     public function addLog(Log $log): self
  1318.     {
  1319.         if (!$this->logs->contains($log)) {
  1320.             $this->logs[] = $log;
  1321.             $log->setUser($this);
  1322.         }
  1323.         return $this;
  1324.     }
  1325.     public function removeLog(Log $log): self
  1326.     {
  1327.         if ($this->logs->removeElement($log)) {
  1328.             // set the owning side to null (unless already changed)
  1329.             if ($log->getUser() === $this) {
  1330.                 $log->setUser(null);
  1331.             }
  1332.         }
  1333.         return $this;
  1334.     }
  1335.     /**
  1336.      * @return Collection|Message[]
  1337.      */
  1338.     public function getMessages(): Collection
  1339.     {
  1340.         return $this->messages;
  1341.     }
  1342.     public function addMessage(Message $message): self
  1343.     {
  1344.         if (!$this->messages->contains($message)) {
  1345.             $this->messages[] = $message;
  1346.             $message->setUser($this);
  1347.         }
  1348.         return $this;
  1349.     }
  1350.     public function removeMessage(Message $message): self
  1351.     {
  1352.         if ($this->messages->removeElement($message)) {
  1353.             // set the owning side to null (unless already changed)
  1354.             if ($message->getUser() === $this) {
  1355.                 $message->setUser(null);
  1356.             }
  1357.         }
  1358.         return $this;
  1359.     }
  1360.     /**
  1361.      * @return Collection|VideoEvent[]
  1362.      */
  1363.     public function getVideoEvents(): Collection
  1364.     {
  1365.         return $this->videoEvents;
  1366.     }
  1367.     public function addVideoEvent(VideoEvent $videoEvent): self
  1368.     {
  1369.         if (!$this->videoEvents->contains($videoEvent)) {
  1370.             $this->videoEvents[] = $videoEvent;
  1371.             $videoEvent->setUser($this);
  1372.         }
  1373.         return $this;
  1374.     }
  1375.     public function removeVideoEvent(VideoEvent $videoEvent): self
  1376.     {
  1377.         if ($this->videoEvents->removeElement($videoEvent)) {
  1378.             // set the owning side to null (unless already changed)
  1379.             if ($videoEvent->getUser() === $this) {
  1380.                 $videoEvent->setUser(null);
  1381.             }
  1382.         }
  1383.         return $this;
  1384.     }
  1385.     /**
  1386.      * @return Collection|UserResponse[]
  1387.      */
  1388.     public function getUserResponses(): Collection
  1389.     {
  1390.         return $this->userResponses;
  1391.     }
  1392.     public function addUserResponse(UserResponse $userResponse): self
  1393.     {
  1394.         if (!$this->userResponses->contains($userResponse)) {
  1395.             $this->userResponses[] = $userResponse;
  1396.             $userResponse->setUser($this);
  1397.         }
  1398.         return $this;
  1399.     }
  1400.     public function removeUserResponse(UserResponse $userResponse): self
  1401.     {
  1402.         if ($this->userResponses->removeElement($userResponse)) {
  1403.             // set the owning side to null (unless already changed)
  1404.             if ($userResponse->getUser() === $this) {
  1405.                 $userResponse->setUser(null);
  1406.             }
  1407.         }
  1408.         return $this;
  1409.     }
  1410.     /**
  1411.      * @return Collection|Favorite[]
  1412.      */
  1413.     public function getTvFavorites(): Collection
  1414.     {
  1415.         return $this->tvFavorites;
  1416.     }
  1417.     public function addTvFavorite(Favorite $tvFavorite): self
  1418.     {
  1419.         if (!$this->tvFavorites->contains($tvFavorite)) {
  1420.             $this->tvFavorites[] = $tvFavorite;
  1421.         }
  1422.         return $this;
  1423.     }
  1424.     public function removeTvFavorite(Favorite $tvFavorite): self
  1425.     {
  1426.         $this->tvFavorites->removeElement($tvFavorite);
  1427.         return $this;
  1428.     }
  1429.     /**
  1430.      * @return Collection|LogEmail[]
  1431.      */
  1432.     public function getLogEmails(): Collection
  1433.     {
  1434.         return $this->logEmails;
  1435.     }
  1436.     public function addLogEmail(LogEmail $logEmail): self
  1437.     {
  1438.         if (!$this->logEmails->contains($logEmail)) {
  1439.             $this->logEmails[] = $logEmail;
  1440.             $logEmail->setUser($this);
  1441.         }
  1442.         return $this;
  1443.     }
  1444.     public function removeLogEmail(LogEmail $logEmail): self
  1445.     {
  1446.         if ($this->logEmails->removeElement($logEmail)) {
  1447.             // set the owning side to null (unless already changed)
  1448.             if ($logEmail->getUser() === $this) {
  1449.                 $logEmail->setUser(null);
  1450.             }
  1451.         }
  1452.         return $this;
  1453.     }
  1454.     /**
  1455.      * @return Collection|Playlist[]
  1456.      */
  1457.     public function getPlaylists(): Collection
  1458.     {
  1459.         return $this->playlists;
  1460.     }
  1461.     public function addPlaylist(Playlist $playlist): self
  1462.     {
  1463.         if (!$this->playlists->contains($playlist)) {
  1464.             $this->playlists[] = $playlist;
  1465.             $playlist->setUser($this);
  1466.         }
  1467.         return $this;
  1468.     }
  1469.     public function removePlaylist(Playlist $playlist): self
  1470.     {
  1471.         if ($this->playlists->removeElement($playlist)) {
  1472.             // set the owning side to null (unless already changed)
  1473.             if ($playlist->getUser() === $this) {
  1474.                 $playlist->setUser(null);
  1475.             }
  1476.         }
  1477.         return $this;
  1478.     }
  1479.     /**
  1480.      * @Groups({"user:write"})
  1481.      */
  1482.     public function setAddPlaylist(Playlist $playlist): self
  1483.     {
  1484.         if (!$this->playlists->contains($playlist)) {
  1485.             $this->playlists[] = $playlist;
  1486.             $playlist->setUser($this);
  1487.         }
  1488.         return $this;
  1489.     }
  1490.     /**
  1491.      * @Groups({"user:write"})
  1492.      */
  1493.     public function setRemovePlaylist(Playlist $playlist): self
  1494.     {
  1495.         if ($this->playlists->removeElement($playlist)) {
  1496.             // set the owning side to null (unless already changed)
  1497.             if ($playlist->getUser() === $this) {
  1498.                 $playlist->setUser(null);
  1499.             }
  1500.         }
  1501.         return $this;
  1502.     }
  1503.     /**
  1504.      * @return Collection|Objective[]
  1505.      */
  1506.     public function getObjectives(): Collection
  1507.     {
  1508.         return $this->objectives;
  1509.     }
  1510.     /**
  1511.      * @return Collection|Objective[]
  1512.      */
  1513.     public function setObjectives(Collection $objectives): self
  1514.     {
  1515.         $this->objectives $objectives;
  1516.         return $this;
  1517.     }
  1518.     public function addObjective(Objective $objective): self
  1519.     {
  1520.         if (!$this->objectives->contains($objective)) {
  1521.             $this->objectives[] = $objective;
  1522.             $objective->addUser($this);
  1523.         }
  1524.         return $this;
  1525.     }
  1526.     public function removeObjective(Objective $objective): self
  1527.     {
  1528.         if ($this->objectives->removeElement($objective)) {
  1529.             $objective->removeUser($this);
  1530.         }
  1531.         return $this;
  1532.     }
  1533.     /**
  1534.      * @return Collection|TeamUser[]
  1535.      */
  1536.     public function getTeamUsers(): Collection
  1537.     {
  1538.         return $this->teamUsers;
  1539.     }
  1540.     public function addTeamUser(TeamUser $teamUser): self
  1541.     {
  1542.         if (!$this->teamUsers->contains($teamUser)) {
  1543.             $this->teamUsers[] = $teamUser;
  1544.             $teamUser->setUser($this);
  1545.         }
  1546.         return $this;
  1547.     }
  1548.     public function removeTeamUser(TeamUser $teamUser): self
  1549.     {
  1550.         if ($this->teamUsers->removeElement($teamUser)) {
  1551.             // set the owning side to null (unless already changed)
  1552.             if ($teamUser->getUser() === $this) {
  1553.                 $teamUser->setUser(null);
  1554.             }
  1555.         }
  1556.         return $this;
  1557.     }
  1558.     /**
  1559.      * @return Collection|TeamplayLog[]
  1560.      */
  1561.     public function getTeamplayLogs(): Collection
  1562.     {
  1563.         return $this->teamplayLogs;
  1564.     }
  1565.     public function addTeamplayLog(TeamplayLog $teamplayLog): self
  1566.     {
  1567.         if (!$this->teamplayLogs->contains($teamplayLog)) {
  1568.             $this->teamplayLogs[] = $teamplayLog;
  1569.             $teamplayLog->setUser($this);
  1570.         }
  1571.         return $this;
  1572.     }
  1573.     public function removeTeamplayLog(TeamplayLog $teamplayLog): self
  1574.     {
  1575.         if ($this->teamplayLogs->removeElement($teamplayLog)) {
  1576.             // set the owning side to null (unless already changed)
  1577.             if ($teamplayLog->getUser() === $this) {
  1578.                 $teamplayLog->setUser(null);
  1579.             }
  1580.         }
  1581.         return $this;
  1582.     }
  1583.     /**
  1584.      * @return Collection|PedometerLog[]
  1585.      */
  1586.     public function getPedometerLogs(): Collection
  1587.     {
  1588.         return $this->pedometerLogs;
  1589.     }
  1590.     public function addPedometerLog(PedometerLog $pedometerLog): self
  1591.     {
  1592.         if (!$this->pedometerLogs->contains($pedometerLog)) {
  1593.             $this->pedometerLogs[] = $pedometerLog;
  1594.             $pedometerLog->setUser($this);
  1595.         }
  1596.         return $this;
  1597.     }
  1598.     public function removePedometerLog(PedometerLog $pedometerLog): self
  1599.     {
  1600.         if ($this->pedometerLogs->removeElement($pedometerLog)) {
  1601.             // set the owning side to null (unless already changed)
  1602.             if ($pedometerLog->getUser() === $this) {
  1603.                 $pedometerLog->setUser(null);
  1604.             }
  1605.         }
  1606.         return $this;
  1607.     }
  1608.     /**
  1609.      * @return Collection<int, UserNotification>
  1610.      */
  1611.     public function getUserNotifications(): Collection
  1612.     {
  1613.         return $this->userNotifications;
  1614.     }
  1615.     public function addUserNotification(UserNotification $userNotification): self
  1616.     {
  1617.         if (!$this->userNotifications->contains($userNotification)) {
  1618.             $this->userNotifications[] = $userNotification;
  1619.             $userNotification->setUser($this);
  1620.         }
  1621.         return $this;
  1622.     }
  1623.     public function removeUserNotification(UserNotification $userNotification): self
  1624.     {
  1625.         if ($this->userNotifications->removeElement($userNotification)) {
  1626.             // set the owning side to null (unless already changed)
  1627.             if ($userNotification->getUser() === $this) {
  1628.                 $userNotification->setUser(null);
  1629.             }
  1630.         }
  1631.         return $this;
  1632.     }
  1633.     /**
  1634.      * @return Collection|AwardLog[]
  1635.      */
  1636.     public function getAwardLogs(): Collection
  1637.     {
  1638.         return $this->awardLogs;
  1639.     }
  1640.     public function addAwardLog(AwardLog $awardLog): self
  1641.     {
  1642.         if (!$this->awardLogs->contains($awardLog)) {
  1643.             $this->awardLogs[] = $awardLog;
  1644.             $awardLog->setUser($this);
  1645.         }
  1646.         return $this;
  1647.     }
  1648.     public function removeAwardLog(AwardLog $awardLog): self
  1649.     {
  1650.         if ($this->awardLogs->removeElement($awardLog)) {
  1651.             // set the owning side to null (unless already changed)
  1652.             if ($awardLog->getUser() === $this) {
  1653.                 $awardLog->setUser(null);
  1654.             }
  1655.         }
  1656.         return $this;
  1657.     }
  1658.     /**
  1659.      * @return Collection|UserVideoTimecode[]
  1660.      */
  1661.     public function getUserVideoTimecodes(): Collection
  1662.     {
  1663.         return $this->userVideoTimecodes;
  1664.     }
  1665.     public function addUserVideoTimecode(UserVideoTimecode $userVideoTimecode): self
  1666.     {
  1667.         if (!$this->userVideoTimecodes->contains($userVideoTimecode)) {
  1668.             $this->userVideoTimecodes[] = $userVideoTimecode;
  1669.             $userVideoTimecode->setUser($this);
  1670.         }
  1671.         return $this;
  1672.     }
  1673.     public function removeUserVideoTimecode(UserVideoTimecode $userVideoTimecode): self
  1674.     {
  1675.         if ($this->userVideoTimecodes->removeElement($userVideoTimecode)) {
  1676.             // set the owning side to null (unless already changed)
  1677.             if ($userVideoTimecode->getUser() === $this) {
  1678.                 $userVideoTimecode->setUser(null);
  1679.             }
  1680.         }
  1681.         return $this;
  1682.     }
  1683.     /**
  1684.      * @return Collection|Notation[]
  1685.      */
  1686.     public function getNotations(): Collection
  1687.     {
  1688.         return $this->notations;
  1689.     }
  1690.     public function addNotation(Notation $notation): self
  1691.     {
  1692.         if (!$this->notations->contains($notation)) {
  1693.             $this->notations[] = $notation;
  1694.             $notation->setUser($this);
  1695.         }
  1696.         return $this;
  1697.     }
  1698.     public function removeNotation(Notation $notation): self
  1699.     {
  1700.         if ($this->notations->removeElement($notation)) {
  1701.             // set the owning side to null (unless already changed)
  1702.             if ($notation->getUser() === $this) {
  1703.                 $notation->setUser(null);
  1704.             }
  1705.         }
  1706.         return $this;
  1707.     }
  1708.     /**
  1709.      * @return Collection|VideoLastValidate[]
  1710.      */
  1711.     public function getVideoLastValidates(): Collection
  1712.     {
  1713.         return $this->videoLastValidates;
  1714.     }
  1715.     public function addVideoLastValidate(VideoLastValidate $videoLastValidate): self
  1716.     {
  1717.         if (!$this->videoLastValidates->contains($videoLastValidate)) {
  1718.             $this->videoLastValidates[] = $videoLastValidate;
  1719.             $videoLastValidate->setUser($this);
  1720.         }
  1721.         return $this;
  1722.     }
  1723.     public function removeVideoLastValidate(VideoLastValidate $videoLastValidate): self
  1724.     {
  1725.         if ($this->videoLastValidates->removeElement($videoLastValidate)) {
  1726.             // set the owning side to null (unless already changed)
  1727.             if ($videoLastValidate->getUser() === $this) {
  1728.                 $videoLastValidate->setUser(null);
  1729.             }
  1730.         }
  1731.         return $this;
  1732.     }
  1733.     /**
  1734.      * @return Collection|VideoLastSeen[]
  1735.      */
  1736.     public function getVideoLastSeens(): Collection
  1737.     {
  1738.         return $this->videoLastSeens;
  1739.     }
  1740.     public function addVideoLastSeen(VideoLastSeen $videoLastSeen): self
  1741.     {
  1742.         if (!$this->videoLastSeens->contains($videoLastSeen)) {
  1743.             $this->videoLastSeens[] = $videoLastSeen;
  1744.             $videoLastSeen->setUser($this);
  1745.         }
  1746.         return $this;
  1747.     }
  1748.     public function removeVideoLastSeen(VideoLastSeen $videoLastSeen): self
  1749.     {
  1750.         if ($this->videoLastSeens->removeElement($videoLastSeen)) {
  1751.             // set the owning side to null (unless already changed)
  1752.             if ($videoLastSeen->getUser() === $this) {
  1753.                 $videoLastSeen->setUser(null);
  1754.             }
  1755.         }
  1756.         return $this;
  1757.     }
  1758.     /**
  1759.      * @return Collection|MoodResponse[]
  1760.      */
  1761.     public function getMoodResponses(): Collection
  1762.     {
  1763.         return $this->moodResponses;
  1764.     }
  1765.     public function addMoodResponse(MoodResponse $moodResponse): self
  1766.     {
  1767.         if (!$this->moodResponses->contains($moodResponse)) {
  1768.             $this->moodResponses[] = $moodResponse;
  1769.             $moodResponse->setUser($this);
  1770.         }
  1771.         return $this;
  1772.     }
  1773.     public function removeMoodResponse(MoodResponse $moodResponse): self
  1774.     {
  1775.         if ($this->moodResponses->removeElement($moodResponse)) {
  1776.             // set the owning side to null (unless already changed)
  1777.             if ($moodResponse->getUser() === $this) {
  1778.                 $moodResponse->setUser(null);
  1779.             }
  1780.         }
  1781.         return $this;
  1782.     }
  1783.     /**
  1784.      * @return Collection|ProgramEvent[]
  1785.      */
  1786.     public function getProgramEvents(): Collection
  1787.     {
  1788.         return $this->programEvents;
  1789.     }
  1790.     public function addProgramEvent(ProgramEvent $programEvent): self
  1791.     {
  1792.         if (!$this->programEvents->contains($programEvent)) {
  1793.             $this->programEvents[] = $programEvent;
  1794.             $programEvent->setUser($this);
  1795.         }
  1796.         return $this;
  1797.     }
  1798.     public function removeProgramEvent(ProgramEvent $programEvent): self
  1799.     {
  1800.         if ($this->programEvents->removeElement($programEvent)) {
  1801.             // set the owning side to null (unless already changed)
  1802.             if ($programEvent->getUser() === $this) {
  1803.                 $programEvent->setUser(null);
  1804.             }
  1805.         }
  1806.         return $this;
  1807.     }
  1808.     /**
  1809.      * @return Collection|DayEvent[]
  1810.      */
  1811.     public function getDayEvents(): Collection
  1812.     {
  1813.         return $this->dayEvents;
  1814.     }
  1815.     public function addDayEvent(DayEvent $dayEvent): self
  1816.     {
  1817.         if (!$this->dayEvents->contains($dayEvent)) {
  1818.             $this->dayEvents[] = $dayEvent;
  1819.             $dayEvent->setUser($this);
  1820.         }
  1821.         return $this;
  1822.     }
  1823.     public function removeDayEvent(DayEvent $dayEvent): self
  1824.     {
  1825.         if ($this->dayEvents->removeElement($dayEvent)) {
  1826.             // set the owning side to null (unless already changed)
  1827.             if ($dayEvent->getUser() === $this) {
  1828.                 $dayEvent->setUser(null);
  1829.             }
  1830.         }
  1831.         return $this;
  1832.     }
  1833.     public function getTvUser(): ?TvUser
  1834.     {
  1835.         return $this->tvUser;
  1836.     }
  1837.     public function setTvUser(?TvUser $tvUser): self
  1838.     {
  1839.         $this->tvUser $tvUser;
  1840.         return $this;
  1841.     }
  1842.     public function isLive(): ?bool
  1843.     {
  1844.         return $this->live;
  1845.     }
  1846.     public function setLive(bool $isLive): self
  1847.     {
  1848.         $this->live $isLive;
  1849.         return $this;
  1850.     }
  1851.     public function isTv(): ?bool
  1852.     {
  1853.         return $this->tv;
  1854.     }
  1855.     public function setTv(bool $isTv): self
  1856.     {
  1857.         $this->tv $isTv;
  1858.         return $this;
  1859.     }
  1860.     /**
  1861.      * @return Collection<int, Chat>
  1862.      */
  1863.     public function getChats(): Collection
  1864.     {
  1865.         return $this->chats;
  1866.     }
  1867.     public function addChat(Chat $chat): self
  1868.     {
  1869.         if (!$this->chats->contains($chat)) {
  1870.             $this->chats[] = $chat;
  1871.         }
  1872.         return $this;
  1873.     }
  1874.     public function removeChat(Chat $chat): self
  1875.     {
  1876.         $this->chats->removeElement($chat);
  1877.         return $this;
  1878.     }
  1879.     /**
  1880.      * @return Collection<int, Invoice>
  1881.      */
  1882.     public function getInvoices(): Collection
  1883.     {
  1884.         return $this->invoices;
  1885.     }
  1886.     public function addInvoice(Invoice $invoice): self
  1887.     {
  1888.         if (!$this->invoices->contains($invoice)) {
  1889.             $this->invoices->add($invoice);
  1890.             $invoice->setUser($this);
  1891.         }
  1892.         return $this;
  1893.     }
  1894.     public function removeInvoice(Invoice $invoice): self
  1895.     {
  1896.         if ($this->invoices->removeElement($invoice)) {
  1897.             // set the owning side to null (unless already changed)
  1898.             if ($invoice->getUser() === $this) {
  1899.                 $invoice->setUser(null);
  1900.             }
  1901.         }
  1902.         return $this;
  1903.     }
  1904.     public function getNotificationPreference(): ?NotificationPreference
  1905.     {
  1906.         return $this->notificationPreference;
  1907.     }
  1908.     public function setNotificationPreference(NotificationPreference $notificationPreference): static
  1909.     {
  1910.         // set the owning side of the relation if necessary
  1911.         if ($notificationPreference->getUser() !== $this) {
  1912.             $notificationPreference->setUser($this);
  1913.         }
  1914.         $this->notificationPreference $notificationPreference;
  1915.         return $this;
  1916.     }
  1917. }