src/Entity/User.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use FOS\UserBundle\Model\User as BaseUser;
  6. use DateTimeInterface;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  12. use App\Repository\UserRepository;
  13. /**
  14.  * @ORM\Entity
  15.  * @ORM\Entity(repositoryClass=UserRepository::class)
  16.  * @UniqueEntity("fakeFullName")
  17.  * @ORM\Table(name="fos_user")
  18.  * @ORM\EntityListeners({"App\EventListener\User\UserListener"})
  19.  * @ORM\HasLifecycleCallbacks
  20.  * @Vich\Uploadable()
  21.  */
  22. class User extends BaseUser
  23. {
  24.     const GENDER = [
  25.         'unknown' => 0,
  26.         'female'  => 1,
  27.         'male'    => 2,
  28.     ];
  29.     const ROLE_ADMIN 'ROLE_ADMIN';
  30.     const ROLE_IMPLEMENTOR 'ROLE_IMPLEMENTOR';
  31.     /******************** BEGIN Summary ********************/
  32.     /**
  33.      * @ORM\Id
  34.      * @ORM\Column(type="integer")
  35.      * @ORM\GeneratedValue(strategy="AUTO")
  36.      */
  37.     protected $id;
  38.     /**
  39.      * @ORM\Column(type="smallint", options={"default": 0})
  40.      */
  41.     private $gender 0;
  42.     /**
  43.      * @ORM\Column(type="string", length=64, nullable=true)
  44.      */
  45.     private $firstname;
  46.     /**
  47.      * @ORM\Column(type="string", length=64, nullable=true)
  48.      */
  49.     private $lastname;
  50.     /**
  51.      * @ORM\Column(type="datetime", nullable=true)
  52.      */
  53.     private $birthday;
  54.     /**
  55.      * @ORM\Column(type="string", length=50, nullable=true)
  56.      */
  57.     private $city;
  58.     /**
  59.      * @ORM\Column(type="string", length=64, nullable=true)
  60.      */
  61.     private $phone;
  62.     /**
  63.      * @ORM\Column(type="string", nullable=true)
  64.      */
  65.     private $facebookProfileLink;
  66.     /**
  67.      * @ORM\Column(type="string", nullable=true)
  68.      */
  69.     private $instagramProfileLink;
  70.     /**
  71.      * @ORM\Column(name="avatar", type="string", nullable=true, options={"comment": "Avatar file path"})
  72.      */
  73.     private $avatar;
  74.     /**
  75.      * @Vich\UploadableField(mapping="user_avatar", fileNameProperty="avatar")
  76.      * @Assert\File(maxSize="4194304")
  77.      * @Assert\Image()
  78.      */
  79.     private $avatarFile;
  80.     /**
  81.      * @ORM\Column(type="text", nullable=true)
  82.      */
  83.     public $deliveryAddress;
  84.     /**
  85.      * Is a member of the press
  86.      *
  87.      * @ORM\Column(type="boolean", options={"default" : false})
  88.      */
  89.     private $press false;
  90.     /**
  91.      * @ORM\Column(type="string", nullable=true)
  92.      */
  93.     private $pressResourceName;
  94.     /**
  95.      * @ORM\Column(type="boolean", options={"default" : false})
  96.      */
  97.     private $hiddenIdentity false;
  98.     /**
  99.      * @ORM\Column(type="string", nullable=true, unique=true)
  100.      */
  101.     private $fakeFullName;
  102.     /**
  103.      * @ORM\Column(type="string", nullable=true)
  104.      */
  105.     private $fakeAvatar;
  106.     /**
  107.      * @ORM\Column(type="boolean", options={"default" : false})
  108.      */
  109.     private $deleted false;
  110.     /**
  111.      * @ORM\Column(type="boolean", options={"default" : false})
  112.      */
  113.     private $policyAgreement false;
  114.     /**
  115.      * @ORM\Column(type="datetime", nullable=true)
  116.      */
  117.     private $registrationDate;
  118.     /**
  119.      * @ORM\Column(type="datetime", nullable=true)
  120.      */
  121.     private $updatedAt;
  122.     /**
  123.      * @ORM\Column(type="integer", options={"default": 0})
  124.      */
  125.     private $currentBalance 0;
  126.     /******************** END Summary **********************/
  127.     /******************** BEGIN Relations ******************/
  128.     /**
  129.      * @ORM\OneToMany(targetEntity="App\Entity\UserBalanceLog", mappedBy="user")
  130.      */
  131.     private $userBalanceLogs;
  132.     /**
  133.      * @ORM\OneToMany(targetEntity="App\Entity\UserToken", mappedBy="user", orphanRemoval=true)
  134.      */
  135.     private $userTokens;
  136.     /**
  137.      * @ORM\OneToMany(targetEntity="App\Entity\ShopOrder", mappedBy="user")
  138.      */
  139.     private $shopOrders;
  140.     /**
  141.      * @ORM\OneToMany(targetEntity="App\Entity\Permission", mappedBy="user")
  142.      */
  143.     private $permissions;
  144.     /**
  145.      * @ORM\OneToMany(targetEntity="App\Entity\ContestParticipation", mappedBy="user")
  146.      */
  147.     private $contestParticipations;
  148.     /**
  149.      * @ORM\OneToMany(targetEntity="App\Entity\DonateAlert", mappedBy="user")
  150.      */
  151.     private $donateAlerts;
  152.     /**
  153.      * @ORM\OneToMany(targetEntity=PermissionShop::class, mappedBy="user")
  154.      */
  155.     private $permissionShops;
  156.     /**
  157.      * @ORM\OneToMany(targetEntity=ActivityLog::class, mappedBy="user")
  158.      */
  159.     private $activityLogs;
  160.     /******************** END Relations ********************/
  161.     public function __construct()
  162.     {
  163.         parent::__construct();
  164.         $this->userBalanceLogs        = new ArrayCollection();
  165.         $this->userTokens             = new ArrayCollection();
  166.         $this->shopOrders             = new ArrayCollection();
  167.         $this->permissions            = new ArrayCollection();
  168.         $this->contestParticipations  = new ArrayCollection();
  169.         $this->donateAlerts           = new ArrayCollection();
  170.         $this->permissionShops = new ArrayCollection();
  171.         $this->activityLogs = new ArrayCollection();
  172.     }
  173.     /******************** BEGIN Getters and Setters ********************/
  174.     /**
  175.      * @return int
  176.      */
  177.     public function getId(): int
  178.     {
  179.         return $this->id;
  180.     }
  181.     /**
  182.      * @return int
  183.      */
  184.     public function getGender(): int
  185.     {
  186.         return $this->gender;
  187.     }
  188.     /**
  189.      * @param int $gender
  190.      * @return User
  191.      */
  192.     public function setGender($gender): self
  193.     {
  194.         $this->gender $gender;
  195.         return $this;
  196.     }
  197.     /**
  198.      * @return string
  199.      */
  200.     public function getStringGender()
  201.     {
  202.         return array_flip(self::GENDER)[$this->getGender()] ?? "undefined";
  203.     }
  204.     /**
  205.      * @return array
  206.      */
  207.     public function getGenderList(): array
  208.     {
  209.         return array_keys(self::GENDER);
  210.     }
  211.     /**
  212.      * @return string|null
  213.      */
  214.     public function getFirstname(): ?string
  215.     {
  216.         return $this->firstname;
  217.     }
  218.     /**
  219.      * @param string|null $firstname
  220.      * @return User
  221.      */
  222.     public function setFirstname($firstname): self
  223.     {
  224.         $this->firstname $firstname;
  225.         return $this;
  226.     }
  227.     /**
  228.      * @return string|null
  229.      */
  230.     public function getLastname(): ?string
  231.     {
  232.         return $this->lastname;
  233.     }
  234.     /**
  235.      * @param string|null $lastname
  236.      * @return User
  237.      */
  238.     public function setLastname($lastname): self
  239.     {
  240.         $this->lastname $lastname;
  241.         return $this;
  242.     }
  243.     /**
  244.      * @return DateTimeInterface|null
  245.      */
  246.     public function getBirthday(): ?DateTimeInterface
  247.     {
  248.         return $this->birthday;
  249.     }
  250.     /**
  251.      * @param DateTimeInterface|null $birthday
  252.      * @return User
  253.      */
  254.     public function setBirthday($birthday): self
  255.     {
  256.         $this->birthday $birthday;
  257.         return $this;
  258.     }
  259.     /**
  260.      * @return string|null
  261.      */
  262.     public function getCity(): ?string
  263.     {
  264.         return $this->city;
  265.     }
  266.     /**
  267.      * @param string|null $city
  268.      * @return User
  269.      */
  270.     public function setCity($city): self
  271.     {
  272.         $this->city $city;
  273.         return $this;
  274.     }
  275.     /**
  276.      * @return string|null
  277.      */
  278.     public function getPhone(): ?string
  279.     {
  280.         return $this->phone;
  281.     }
  282.     /**
  283.      * @param string|null $phone
  284.      * @return User
  285.      */
  286.     public function setPhone($phone): self
  287.     {
  288.         $this->phone $phone;
  289.         return $this;
  290.     }
  291.     /**
  292.      * @return string|null
  293.      */
  294.     public function getFacebookProfileLink(): ?string
  295.     {
  296.         return $this->facebookProfileLink;
  297.     }
  298.     /**
  299.      * @param string|null $facebookProfileLink
  300.      * @return User
  301.      */
  302.     public function setFacebookProfileLink($facebookProfileLink): self
  303.     {
  304.         $this->facebookProfileLink $facebookProfileLink;
  305.         return $this;
  306.     }
  307.     /**
  308.      * @return string|null
  309.      */
  310.     public function getInstagramProfileLink(): ?string
  311.     {
  312.         return $this->instagramProfileLink;
  313.     }
  314.     /**
  315.      * @param string|null $instagramProfileLink
  316.      * @return User
  317.      */
  318.     public function setInstagramProfileLink($instagramProfileLink): self
  319.     {
  320.         $this->instagramProfileLink $instagramProfileLink;
  321.         return $this;
  322.     }
  323.     /**
  324.      * @return string|null
  325.      */
  326.     public function getAvatar(): ?string
  327.     {
  328.         return $this->avatar;
  329.     }
  330.     /**
  331.      * @param string $avatar
  332.      * @return User
  333.      */
  334.     public function setAvatar($avatar): self
  335.     {
  336.         $this->avatar $avatar;
  337.         return $this;
  338.     }
  339.     /**
  340.      * @return File
  341.      */
  342.     public function getAvatarFile(): ?File
  343.     {
  344.         return $this->avatarFile;
  345.     }
  346.     /**
  347.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $file
  348.      * @throws \Exception
  349.      */
  350.     public function setAvatarFile(File $file null)
  351.     {
  352.         $this->avatarFile $file;
  353.         if (null !== $file) {
  354.             $this->updatedAt = new \DateTime();
  355.         }
  356.     }
  357.     /**
  358.      * @return string|null
  359.      */
  360.     public function getAvatarUrl(): ?string
  361.     {
  362.         return $this->avatar '/uploads/files/user/' $this->avatar null;
  363.     }
  364.     /**
  365.      * @return string|null
  366.      */
  367.     public function getDeliveryAddress(): ?string
  368.     {
  369.         return $this->deliveryAddress;
  370.     }
  371.     /**
  372.      * @param string|null $deliveryAddress
  373.      * @return User
  374.      */
  375.     public function setDeliveryAddress($deliveryAddress): self
  376.     {
  377.         $this->deliveryAddress $deliveryAddress;
  378.         return $this;
  379.     }
  380.     /**
  381.      * @return bool
  382.      */
  383.     public function isPress(): bool
  384.     {
  385.         return $this->press;
  386.     }
  387.     /**
  388.      * @param bool $press
  389.      * @return User
  390.      */
  391.     public function setPress($press): self
  392.     {
  393.         $this->press $press;
  394.         return $this;
  395.     }
  396.     /**
  397.      * @return string
  398.      */
  399.     public function getPressResourceName(): ?string
  400.     {
  401.         return $this->pressResourceName;
  402.     }
  403.     /**
  404.      * @param string $pressResourceName
  405.      * @return User
  406.      */
  407.     public function setPressResourceName($pressResourceName): self
  408.     {
  409.         $this->pressResourceName $pressResourceName;
  410.         return $this;
  411.     }
  412.     /**
  413.      * @return bool
  414.      */
  415.     public function isHiddenIdentity(): bool
  416.     {
  417.         return $this->hiddenIdentity;
  418.     }
  419.     /**
  420.      * @param bool $hiddenIdentity
  421.      * @return User
  422.      */
  423.     public function setHiddenIdentity($hiddenIdentity): self
  424.     {
  425.         $this->hiddenIdentity $hiddenIdentity;
  426.         return $this;
  427.     }
  428.     /**
  429.      * @return string|null
  430.      */
  431.     public function getFakeFullName()
  432.     {
  433.         return $this->fakeFullName;
  434.     }
  435.     /**
  436.      * @param string|null $fakeFullName
  437.      * @return User
  438.      */
  439.     public function setFakeFullName($fakeFullName): self
  440.     {
  441.         $this->fakeFullName $fakeFullName;
  442.         return $this;
  443.     }
  444.     /**
  445.      * @return string|null
  446.      */
  447.     public function getFakeAvatar()
  448.     {
  449.         return $this->fakeAvatar;
  450.     }
  451.     /**
  452.      * @param string|null $fakeAvatar
  453.      * @return User
  454.      */
  455.     public function setFakeAvatar($fakeAvatar): self
  456.     {
  457.         $this->fakeAvatar $fakeAvatar;
  458.         return $this;
  459.     }
  460.     /**
  461.      * @return bool
  462.      */
  463.     public function isDeleted(): bool
  464.     {
  465.         return $this->deleted;
  466.     }
  467.     /**
  468.      * @param bool $deleted
  469.      * @return User
  470.      */
  471.     public function setDeleted($deleted): self
  472.     {
  473.         $this->deleted $deleted;
  474.         return $this;
  475.     }
  476.     /**
  477.      * @return bool
  478.      */
  479.     public function getPolicyAgreement(): bool
  480.     {
  481.         return $this->policyAgreement;
  482.     }
  483.     /**
  484.      * @param bool $policyAgreement
  485.      * @return User
  486.      */
  487.     public function setPolicyAgreement($policyAgreement): self
  488.     {
  489.         $this->policyAgreement $policyAgreement;
  490.         return $this;
  491.     }
  492.     /**
  493.      * @return DateTimeInterface|null
  494.      */
  495.     public function getRegistrationDate(): ?DateTimeInterface
  496.     {
  497.         return $this->registrationDate;
  498.     }
  499.     /**
  500.      * @param DateTimeInterface $registrationDate
  501.      * @return User
  502.      */
  503.     public function setRegistrationDate($registrationDate): self
  504.     {
  505.         $this->registrationDate $registrationDate;
  506.         return $this;
  507.     }
  508.     /**
  509.      * @return \DateTimeInterface|null
  510.      */
  511.     public function getUpdatedAt(): ?\DateTimeInterface
  512.     {
  513.         return $this->updatedAt;
  514.     }
  515.     /**
  516.      * @return integer
  517.      */
  518.     public function getCurrentBalance(): int
  519.     {
  520.         return $this->currentBalance;
  521.     }
  522.     /**
  523.      * @param integer $currentBalance
  524.      * @return User
  525.      */
  526.     public function setCurrentBalance($currentBalance): self
  527.     {
  528.         $this->currentBalance $currentBalance;
  529.         return $this;
  530.     }
  531.     /**
  532.      * @return Collection
  533.      */
  534.     public function getUserBalanceLogs(): Collection
  535.     {
  536.         return $this->userBalanceLogs;
  537.     }
  538.     /**
  539.      * @return Collection|ShopOrder[]
  540.      */
  541.     public function getShopOrders(): Collection
  542.     {
  543.         return $this->shopOrders;
  544.     }
  545.     /**
  546.      * @return Collection|Permission[]
  547.      */
  548.     public function getPermissions(): Collection
  549.     {
  550.         return $this->permissions;
  551.     }
  552.     /**
  553.      * @return Collection|ContestParticipation[]
  554.      */
  555.     public function getContestParticipations(): Collection
  556.     {
  557.         return $this->contestParticipations;
  558.     }
  559.     /**
  560.      * @return Collection|DonateAlert[]
  561.      */
  562.     public function getDonateAlerts(): Collection
  563.     {
  564.         return $this->donateAlerts;
  565.     }
  566.     /**
  567.      * @return Collection|UserToken[]
  568.      */
  569.     public function getUserTokens(): Collection
  570.     {
  571.         return $this->userTokens;
  572.     }
  573.     /**
  574.      * @param UserToken $userToken
  575.      * @return User
  576.      */
  577.     public function addUserToken(UserToken $userToken): self
  578.     {
  579.         if (!$this->userTokens->contains($userToken)) {
  580.             $this->userTokens[] = $userToken;
  581.             $userToken->setUser($this);
  582.         }
  583.         return $this;
  584.     }
  585.     /**
  586.      * @param UserToken $userToken
  587.      * @return User
  588.      */
  589.     public function removeUserToken(UserToken $userToken): self
  590.     {
  591.         if ($this->userTokens->contains($userToken)) {
  592.             $this->userTokens->removeElement($userToken);
  593.             // set the owning side to null (unless already changed)
  594.             if ($userToken->getUser() === $this) {
  595.                 $userToken->setUser(null);
  596.             }
  597.         }
  598.         return $this;
  599.     }
  600.     /******************** END Getters and Setters ********************/
  601.     /**
  602.      * @return bool
  603.      */
  604.     public function isAdmin()
  605.     {
  606.         return $this->hasRole(self::ROLE_ADMIN);
  607.     }
  608.     /**
  609.      * @return bool
  610.      */
  611.     public function isImplementor()
  612.     {
  613.         return $this->hasRole(self::ROLE_IMPLEMENTOR);
  614.     }
  615.     /**
  616.      * @ORM\PrePersist
  617.      *
  618.      * @throws \Exception
  619.      */
  620.     public function onPrePersist()
  621.     {
  622.         $this->registrationDate = new \DateTime('now');
  623.     }
  624.     /**
  625.      * @ORM\PreUpdate
  626.      *
  627.      * @throws \Exception
  628.      */
  629.     public function onPreUpdate()
  630.     {
  631.         $this->updatedAt = new \DateTime('now');
  632.     }
  633.     public function getPress(): ?bool
  634.     {
  635.         return $this->press;
  636.     }
  637.     public function getDeleted(): ?bool
  638.     {
  639.         return $this->deleted;
  640.     }
  641.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  642.     {
  643.         $this->updatedAt $updatedAt;
  644.         return $this;
  645.     }
  646.     public function addUserBalanceLog(UserBalanceLog $userBalanceLog): self
  647.     {
  648.         if (!$this->userBalanceLogs->contains($userBalanceLog)) {
  649.             $this->userBalanceLogs[] = $userBalanceLog;
  650.             $userBalanceLog->setUser($this);
  651.         }
  652.         return $this;
  653.     }
  654.     public function removeUserBalanceLog(UserBalanceLog $userBalanceLog): self
  655.     {
  656.         if ($this->userBalanceLogs->contains($userBalanceLog)) {
  657.             $this->userBalanceLogs->removeElement($userBalanceLog);
  658.             // set the owning side to null (unless already changed)
  659.             if ($userBalanceLog->getUser() === $this) {
  660.                 $userBalanceLog->setUser(null);
  661.             }
  662.         }
  663.         return $this;
  664.     }
  665.     public function addShopOrder(ShopOrder $shopOrder): self
  666.     {
  667.         if (!$this->shopOrders->contains($shopOrder)) {
  668.             $this->shopOrders[] = $shopOrder;
  669.             $shopOrder->setUser($this);
  670.         }
  671.         return $this;
  672.     }
  673.     public function removeShopOrder(ShopOrder $shopOrder): self
  674.     {
  675.         if ($this->shopOrders->contains($shopOrder)) {
  676.             $this->shopOrders->removeElement($shopOrder);
  677.             // set the owning side to null (unless already changed)
  678.             if ($shopOrder->getUser() === $this) {
  679.                 $shopOrder->setUser(null);
  680.             }
  681.         }
  682.         return $this;
  683.     }
  684.     public function getHiddenIdentity(): ?bool
  685.     {
  686.         return $this->hiddenIdentity;
  687.     }
  688.     public function addPermission(Permission $permission): self
  689.     {
  690.         if (!$this->permissions->contains($permission)) {
  691.             $this->permissions[] = $permission;
  692.             $permission->setUser($this);
  693.         }
  694.         return $this;
  695.     }
  696.     public function removePermission(Permission $permission): self
  697.     {
  698.         if ($this->permissions->contains($permission)) {
  699.             $this->permissions->removeElement($permission);
  700.             // set the owning side to null (unless already changed)
  701.             if ($permission->getUser() === $this) {
  702.                 $permission->setUser(null);
  703.             }
  704.         }
  705.         return $this;
  706.     }
  707.     public function addContestParticipation(ContestParticipation $contestParticipation): self
  708.     {
  709.         if (!$this->contestParticipations->contains($contestParticipation)) {
  710.             $this->contestParticipations[] = $contestParticipation;
  711.             $contestParticipation->setUser($this);
  712.         }
  713.         return $this;
  714.     }
  715.     public function removeContestParticipation(ContestParticipation $contestParticipation): self
  716.     {
  717.         if ($this->contestParticipations->contains($contestParticipation)) {
  718.             $this->contestParticipations->removeElement($contestParticipation);
  719.             // set the owning side to null (unless already changed)
  720.             if ($contestParticipation->getUser() === $this) {
  721.                 $contestParticipation->setUser(null);
  722.             }
  723.         }
  724.         return $this;
  725.     }
  726.     public function addDonateAlert(DonateAlert $donateAlert): self
  727.     {
  728.         if (!$this->donateAlerts->contains($donateAlert)) {
  729.             $this->donateAlerts[] = $donateAlert;
  730.             $donateAlert->setUser($this);
  731.         }
  732.         return $this;
  733.     }
  734.     public function removeDonateAlert(DonateAlert $donateAlert): self
  735.     {
  736.         if ($this->donateAlerts->contains($donateAlert)) {
  737.             $this->donateAlerts->removeElement($donateAlert);
  738.             // set the owning side to null (unless already changed)
  739.             if ($donateAlert->getUser() === $this) {
  740.                 $donateAlert->setUser(null);
  741.             }
  742.         }
  743.         return $this;
  744.     }
  745.     /**
  746.      * @return Collection|PermissionShop[]
  747.      */
  748.     public function getPermissionShops(): Collection
  749.     {
  750.         return $this->permissionShops;
  751.     }
  752.     public function addPermissionShop(PermissionShop $permissionShop): self
  753.     {
  754.         if (!$this->permissionShops->contains($permissionShop)) {
  755.             $this->permissionShops[] = $permissionShop;
  756.             $permissionShop->setUser($this);
  757.         }
  758.         return $this;
  759.     }
  760.     public function removePermissionShop(PermissionShop $permissionShop): self
  761.     {
  762.         if ($this->permissionShops->contains($permissionShop)) {
  763.             $this->permissionShops->removeElement($permissionShop);
  764.             // set the owning side to null (unless already changed)
  765.             if ($permissionShop->getUser() === $this) {
  766.                 $permissionShop->setUser(null);
  767.             }
  768.         }
  769.         return $this;
  770.     }
  771.     /**
  772.      * @return Collection
  773.      */
  774.     public function getActivityLogs(): Collection
  775.     {
  776.         return $this->activityLogs;
  777.     }
  778.     /**
  779.      * @param ActivityLog $activityLog
  780.      * @return $this
  781.      */
  782.     public function addActivityLog(ActivityLog $activityLog): self
  783.     {
  784.         if (!$this->activityLogs->contains($activityLog)) {
  785.             $this->activityLogs[] = $activityLog;
  786.             $activityLog->setUser($this);
  787.         }
  788.         return $this;
  789.     }
  790.     /**
  791.      * @param ActivityLog $activityLog
  792.      * @return $this
  793.      */
  794.     public function removeActivityLog(ActivityLog $activityLog): self
  795.     {
  796.         if ($this->activityLogs->contains($activityLog)) {
  797.             $this->activityLogs->removeElement($activityLog);
  798.             // set the owning side to null (unless already changed)
  799.             if ($activityLog->getUser() === $this) {
  800.                 $activityLog->setUser(null);
  801.             }
  802.         }
  803.         return $this;
  804.     }
  805. }