src/Entity/SonataUserUser.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime as DateTimeAlias;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Sonata\UserBundle\Entity\BaseUser;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. //use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;
  11. use Gedmo\Mapping\Annotation as Gedmo;
  12. /**
  13.  * @ORM\Entity
  14.  * @ORM\Table(name="user__user")
  15.  */
  16. class SonataUserUser extends BaseUser
  17. {
  18.     /**
  19.     * @ORM\Id
  20.     * @ORM\Column(type="integer")
  21.     * @ORM\GeneratedValue(strategy="AUTO")
  22.     */
  23.     protected $id;
  24.     public function getId(): ?int
  25.     {
  26.         return $this->id;
  27.     }
  28.     /**
  29.     * @var string $name
  30.     *
  31.     * @ORM\Column(type="string", nullable=true)
  32.     */
  33.     protected $name;
  34.     /**
  35.     * @var boolean $intranet
  36.     *
  37.     * @ORM\Column(type="boolean", nullable=true)
  38.     */
  39.     protected $intranet;
  40.     /**
  41.     * @var DateTimeAlias $birthday
  42.     *
  43.     * @ORM\Column(type="date", nullable=true)
  44.     */
  45.     protected $birthday;
  46.     /**
  47.     * @var string $image
  48.     *
  49.     * @ORM\ManyToOne(targetEntity="App\Entity\SonataMediaMedia", cascade = {"persist"})
  50.     * @ORM\JoinColumn(name="image_id", referencedColumnName="id", onDelete="SET NULL")
  51.     */
  52.     protected $image;
  53.     /**
  54.     * @ORM\OneToMany(targetEntity = "App\Entity\Order", mappedBy="user")
  55.     */
  56.     protected $orders;
  57.     /**
  58.     * @var string $user_pass_hash
  59.     *
  60.     * @ORM\Column(type="string", nullable=true)
  61.     */
  62.     protected $user_pass_hash;
  63.     public function __construct()
  64.     {
  65.         $this->orders = new ArrayCollection();
  66.     }
  67.     public function getBirthday(): DateTimeAlias
  68.     {
  69.         return $this->birthday?:new DateTimeAlias('now');
  70.     }
  71.     public function setBirthday(DateTimeAlias $birthday): void
  72.     {
  73.         $this->birthday $birthday;
  74.     }
  75.     public function getImage(): ?SonataMediaMedia
  76.     {
  77.         return $this->image;
  78.     }
  79.     public function setImage(?SonataMediaMedia $image): static
  80.     {
  81.         $this->image $image;
  82.         return $this;
  83.     }
  84.     public function isIntranet(): ?bool
  85.     {
  86.         return $this->intranet;
  87.     }
  88.     public function setIntranet(?bool $intranet): static
  89.     {
  90.         $this->intranet $intranet;
  91.         return $this;
  92.     }
  93.     public function getName(): ?string
  94.     {
  95.         return $this->name;
  96.     }
  97.     public function setName(?string $name): static
  98.     {
  99.         $this->name $name;
  100.         return $this;
  101.     }
  102.     public function getUserPassHash(): string
  103.     {
  104.         return $this->user_pass_hash;
  105.     }
  106.     public function setUserPassHash(string $user_pass_hash): void
  107.     {
  108.         $this->user_pass_hash $user_pass_hash;
  109.     }
  110.     /**
  111.      * @return Collection<int, Order>
  112.      */
  113.     public function getOrders(): Collection
  114.     {
  115.         return $this->orders;
  116.     }
  117.     public function addOrder(Order $order): static
  118.     {
  119.         if (!$this->orders->contains($order)) {
  120.             $this->orders->add($order);
  121.             $order->setUser($this);
  122.         }
  123.         return $this;
  124.     }
  125.     public function removeOrder(Order $order): static
  126.     {
  127.         if ($this->orders->removeElement($order)) {
  128.             // set the owning side to null (unless already changed)
  129.             if ($order->getUser() === $this) {
  130.                 $order->setUser(null);
  131.             }
  132.         }
  133.         return $this;
  134.     }
  135. }